[GRASS-SVN] r50152 - grass/branches/develbranch_6/lib/g3d

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Jan 12 09:09:58 EST 2012


Author: neteler
Date: 2012-01-12 06:09:57 -0800 (Thu, 12 Jan 2012)
New Revision: 50152

Modified:
   grass/branches/develbranch_6/lib/g3d/cache.c
Log:
Corrected uninitialized values and invalid memory access (backport from trunk, r49787)

Modified: grass/branches/develbranch_6/lib/g3d/cache.c
===================================================================
--- grass/branches/develbranch_6/lib/g3d/cache.c	2012-01-12 14:09:40 UTC (rev 50151)
+++ grass/branches/develbranch_6/lib/g3d/cache.c	2012-01-12 14:09:57 UTC (rev 50152)
@@ -90,6 +90,7 @@
 		    int (*eltLoadFun) (), void *eltLoadFunData)
 {
     G3D_cache *tmp;
+    int i;
 
     tmp = G3d_malloc(sizeof(G3D_cache));
     if (tmp == NULL) {
@@ -115,6 +116,10 @@
 	return (void *)NULL;
     }
 
+    /* Init the cache lock */
+    for(i = 0; i < tmp->nofElts; i++)
+        tmp->locks[i] = 0;
+
     tmp->eltRemoveFun = eltRemoveFun;
     tmp->eltRemoveFunData = eltRemoveFunData;
     tmp->eltLoadFun = eltLoadFun;
@@ -196,7 +201,7 @@
 	return;
     }
 
-    if (IS_NOT_IN_QUEUE_ELT(left))
+    if (left >= 0 && IS_NOT_IN_QUEUE_ELT(left))
 	G3d_fatalError("cache_queue_enqueue: position not in queue");
 
 



More information about the grass-commit mailing list