[GRASS-SVN] r49787 - grass/trunk/lib/raster3d

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Dec 16 08:42:01 EST 2011


Author: huhabla
Date: 2011-12-16 05:42:01 -0800 (Fri, 16 Dec 2011)
New Revision: 49787

Modified:
   grass/trunk/lib/raster3d/cache1.c
Log:
Corrected uninitialized values and invalid memory access


Modified: grass/trunk/lib/raster3d/cache1.c
===================================================================
--- grass/trunk/lib/raster3d/cache1.c	2011-12-16 11:30:32 UTC (rev 49786)
+++ grass/trunk/lib/raster3d/cache1.c	2011-12-16 13:42:01 UTC (rev 49787)
@@ -90,6 +90,7 @@
 		    int (*eltLoadFun) (), void *eltLoadFunData)
 {
     RASTER3D_cache *tmp;
+    int i;
 
     tmp = Rast3d_malloc(sizeof(RASTER3D_cache));
     if (tmp == NULL) {
@@ -114,7 +115,10 @@
 	Rast3d_error("Rast3d_cache_new: error in Rast3d_malloc");
 	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 +200,7 @@
 	return;
     }
 
-    if (IS_NOT_IN_QUEUE_ELT(left))
+    if (left >= 0 && IS_NOT_IN_QUEUE_ELT(left))
 	Rast3d_fatal_error("cache_queue_enqueue: position not in queue");
 
 



More information about the grass-commit mailing list