Ver código fonte

Bugfix, the open range file descriptor must be closed in case the cell range file exists but its empty.

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@57335 15284696-431f-4ddb-bdfa-cd5b030d7da7
Soeren Gebbert 11 anos atrás
pai
commit
f3c9f6b89d
1 arquivos alterados com 4 adições e 1 exclusões
  1. 4 1
      lib/raster/range.c

+ 4 - 1
lib/raster/range.c

@@ -209,8 +209,11 @@ int Rast_read_range(const char *name, const char *mapset, struct Range *range)
 	}
 
 	/* if range file exists but empty */
-	if (!fgets(buf, sizeof buf, fd))
+        if (!fgets(buf, sizeof buf, fd)) {
+            if (fd)
+                fclose(fd);
 	    return 2;
+        }
 
 	x[0] = x[1] = x[2] = x[3] = 0;
 	count = sscanf(buf, "%d%d%d%d", &x[0], &x[1], &x[2], &x[3]);