Bladeren bron

Fixed segfault caused by incorrect free of not allocated raster
buffer


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@46921 15284696-431f-4ddb-bdfa-cd5b030d7da7

Soeren Gebbert 14 jaren geleden
bovenliggende
commit
b2d29dab8c
1 gewijzigde bestanden met toevoegingen van 6 en 5 verwijderingen
  1. 6 5
      raster/r.colors/stats.c

+ 6 - 5
raster/r.colors/stats.c

@@ -50,7 +50,7 @@ int get_stats(const char *name, const char *mapset, struct Cell_stats *statf) {
 void get_fp_stats(const char *name, const char *mapset,
         struct FP_stats *statf,
         DCELL min, DCELL max, int geometric, int geom_abs, int type) {
-    DCELL *dcell;
+    DCELL *dcell = NULL;
     int row, col, depth, nrows, ncols, ndepths = 1;
     int fd;
     G3D_Map *map3d = NULL;
@@ -147,10 +147,11 @@ void get_fp_stats(const char *name, const char *mapset,
 
     G_percent(row, nrows, 2);
 
-    if (type == RASTER_TYPE)
+    if (type == RASTER_TYPE) {
         Rast_close(fd);
-    else
+	if(dcell)
+    	    G_free(dcell);
+    } else {
         G3d_closeCell(map3d);
-
-    G_free(dcell);
+    }
 }