Browse Source

rasterlib: fix memory leak for compressed null files

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@69751 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 8 years ago
parent
commit
e23d5cb0b9
2 changed files with 6 additions and 0 deletions
  1. 5 0
      lib/raster/close.c
  2. 1 0
      lib/raster/open.c

+ 5 - 0
lib/raster/close.c

@@ -155,6 +155,8 @@ static int close_old(int fd)
 
     if (fcb->null_bits)
 	G_free(fcb->null_bits);
+    if (fcb->null_row_ptr)
+	G_free(fcb->null_row_ptr);
     if (fcb->null_fd >= 0)
 	close(fcb->null_fd);
     fcb->null_fd = -1;
@@ -478,6 +480,9 @@ static int close_new(int fd, int ok)
 
     G_free(fcb->null_bits);
 
+    if (fcb->null_row_ptr)
+	G_free(fcb->null_row_ptr);
+
     if (fcb->map_type != CELL_TYPE)
 	Rast_quant_free(&fcb->quant);
 

+ 1 - 0
lib/raster/open.c

@@ -708,6 +708,7 @@ static int open_raster_new(const char *name, int open_mode,
 
     fcb->null_temp_name = tempname;
 
+    fcb->null_row_ptr = NULL;
     if (R__.compress_nulls) {
 	fcb->null_row_ptr = G_calloc(fcb->cellhd.rows + 1, sizeof(off_t));
 	G_zero(fcb->row_ptr, (fcb->cellhd.rows + 1) * sizeof(off_t));