Jelajahi Sumber

r.volume: change int type to prevent overflow, see https://trac.osgeo.org/grass/ticket/3004 (merge from trunk, https://trac.osgeo.org/grass/changeset/68376)

git-svn-id: https://svn.osgeo.org/grass/grass/branches/releasebranch_7_0@68378 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová 9 tahun lalu
induk
melakukan
e726410772
3 mengubah file dengan 6 tambahan dan 5 penghapusan
  1. 1 1
      raster/r.volume/centroids.c
  2. 1 1
      raster/r.volume/local_proto.h
  3. 4 3
      raster/r.volume/main.c

+ 1 - 1
raster/r.volume/centroids.c

@@ -22,7 +22,7 @@
 int centroids(int fd,		/* File descriptor of map layer to process */
 	      /* This file is assumed to be opened before calling */
 	      /*   centroids. */
-	      int *e, int *n,	/* Pointers to arrays at least max+1 long */
+	      unsigned long *e, unsigned long *n,	/* Pointers to arrays at least max+1 long */
 	      int method,	/* 0, 1, or 2; see above. */
 	      int max)
 {				/* Highest positive cat number in map layer */

+ 1 - 1
raster/r.volume/local_proto.h

@@ -1,3 +1,3 @@
 #define SEP "-----------------------------------------------------------------------------"
 
-int centroids(int, int *, int *, int, int);
+int centroids(int, unsigned long*, unsigned long*, int, int);

+ 4 - 3
raster/r.volume/main.c

@@ -41,7 +41,8 @@ int main(int argc, char *argv[])
     CELL i, max;
 
     int row, col, rows, cols;
-    int out_mode, use_MASK, *n, *e;
+    int out_mode, use_MASK;
+    unsigned long *n, *e;
     long int *count;
     int fd_data, fd_clump;
 
@@ -216,8 +217,8 @@ int main(int argc, char *argv[])
     G_free(clump_buf);
 
     /* data lists for centroids of clumps */
-    e = (int *)G_malloc((max + 1) * sizeof(int));
-    n = (int *)G_malloc((max + 1) * sizeof(int));
+    e = (unsigned long*)G_malloc((max + 1) * sizeof(unsigned long));
+    n = (unsigned long*)G_malloc((max + 1) * sizeof(unsigned long));
 
     i = centroids(fd_clump, e, n, 1, max);