[GRASS-SVN] r74198 - in grass/trunk/vector: v.what.rast v.what.rast3

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Mar 9 06:28:54 PST 2019


Author: mmetz
Date: 2019-03-09 06:28:54 -0800 (Sat, 09 Mar 2019)
New Revision: 74198

Modified:
   grass/trunk/vector/v.what.rast/search.c
   grass/trunk/vector/v.what.rast3/search.c
Log:
v.what.rast(3): prevent integer overflow

Modified: grass/trunk/vector/v.what.rast/search.c
===================================================================
--- grass/trunk/vector/v.what.rast/search.c	2019-03-09 14:26:52 UTC (rev 74197)
+++ grass/trunk/vector/v.what.rast/search.c	2019-03-09 14:28:54 UTC (rev 74198)
@@ -5,7 +5,10 @@
 {
     const struct order *i = ii, *j = jj;
 
-    return i->row - j->row;
+    if (i->row < j->row)
+	return -1;
+
+    return (i->row > j->row);
 }
 
 /* for qsort, order list by cat */
@@ -13,7 +16,10 @@
 {
     const struct order *i = ii, *j = jj;
 
-    return i->cat - j->cat;
+    if (i->cat < j->cat)
+	return -1;
+
+    return (i->cat > j->cat);
 }
 
 /* for bsearch, find cat */

Modified: grass/trunk/vector/v.what.rast3/search.c
===================================================================
--- grass/trunk/vector/v.what.rast3/search.c	2019-03-09 14:26:52 UTC (rev 74197)
+++ grass/trunk/vector/v.what.rast3/search.c	2019-03-09 14:28:54 UTC (rev 74198)
@@ -5,7 +5,10 @@
 {
     const struct order *i = ii, *j = jj;
 
-    return i->cat - j->cat;
+    if (i->cat < j->cat)
+	return -1;
+
+    return (i->cat > j->cat);
 }
 
 /* for bsearch, find cat */



More information about the grass-commit mailing list