diff layer/LinearNumericalScale.cpp @ 864:3ca3b8fbbcee

Correct some really stupid fixed-length string stuff, including a genuine stack overflow that causes a crash on OS/X for certain colour 3d plot data.
author Chris Cannam
date Mon, 29 Sep 2014 13:27:13 +0100
parents 1d526ba11a24
children e0f08e108064
line wrap: on
line diff
--- a/layer/LinearNumericalScale.cpp	Fri Sep 12 11:50:26 2014 +0100
+++ b/layer/LinearNumericalScale.cpp	Mon Sep 29 13:27:13 2014 +0100
@@ -42,7 +42,8 @@
     float val = minf;
     float inc = (maxf - val) / n;
 
-    char buffer[40];
+    const int buflen = 40;
+    char buffer[buflen];
 
     int w = getWidth(v, paint) + x0;
 
@@ -86,7 +87,7 @@
 	    continue;
         }
 
-	sprintf(buffer, "%.*f", dp, dispval);
+	snprintf(buffer, buflen, "%.*f", dp, dispval);
 
 	QString label = QString(buffer);