[GRASS-SVN] r56859 - grass/branches/releasebranch_6_4/display/d.barscale

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Jun 20 22:19:21 PDT 2013


Author: hamish
Date: 2013-06-20 22:19:21 -0700 (Thu, 20 Jun 2013)
New Revision: 56859

Modified:
   grass/branches/releasebranch_6_4/display/d.barscale/draw_scale.c
   grass/branches/releasebranch_6_4/display/d.barscale/main.c
Log:
avoid segfault when traversing >5000 miles (merge from devbr6)

Modified: grass/branches/releasebranch_6_4/display/d.barscale/draw_scale.c
===================================================================
--- grass/branches/releasebranch_6_4/display/d.barscale/draw_scale.c	2013-06-21 05:07:32 UTC (rev 56858)
+++ grass/branches/releasebranch_6_4/display/d.barscale/draw_scale.c	2013-06-21 05:19:21 UTC (rev 56859)
@@ -56,7 +56,7 @@
 	"100 miles", 160934.400, 1000000., 10}, {
 	"500 miles", 804672.000, 2000000., 5}, {
 	"1000 miles", 1609344.000, 10000000., 10}, {
-    "5000 miles", 8046720.000, 20000000., 5},}
+	"5000 miles", 8046720.000, 20000000., 5},}
 };
 
 int draw_scale(char *save, int toptext, int size)
@@ -138,6 +138,10 @@
     if (!incr)
 	return (-1);
 
+    /* beyond the maximum just make the longest scale narrower */
+    if (incr >= NUMSCALES)
+	incr = NUMSCALES - 1;
+
     line_len = D_get_u_to_d_xconv() * scales[incr].size
 	/ G_database_units_to_meters_factor();
     seg_len = line_len / scales[incr].seg;

Modified: grass/branches/releasebranch_6_4/display/d.barscale/main.c
===================================================================
--- grass/branches/releasebranch_6_4/display/d.barscale/main.c	2013-06-21 05:07:32 UTC (rev 56858)
+++ grass/branches/releasebranch_6_4/display/d.barscale/main.c	2013-06-21 05:19:21 UTC (rev 56859)
@@ -175,7 +175,6 @@
 	char cmdbuf[512];
 
 	sprintf(cmdbuf, "%s at=%.2f,%.2f", argv[0], east, north);
-
 	sprintf(cmdbuf, "%s bcolor=%s", cmdbuf, opt1->answer);
 	sprintf(cmdbuf, "%s tcolor=%s", cmdbuf, opt2->answer);
 	if (top->answer)



More information about the grass-commit mailing list