Mercurial > hg > svgui
diff layer/LogNumericalScale.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 | b81f21f2c4c3 |
children | e0f08e108064 |
line wrap: on
line diff
--- a/layer/LogNumericalScale.cpp Fri Sep 12 11:50:26 2014 +0100 +++ b/layer/LogNumericalScale.cpp Mon Sep 29 13:27:13 2014 +0100 @@ -55,7 +55,8 @@ cerr << "min = " << minlog << ", max = " << maxlog << ", inc = " << inc << ", minDispInc = " << minDispInc << endl; #endif - char buffer[40]; + const int buflen = 40; + char buffer[buflen]; float round = 1.f; int dp = 0; @@ -104,7 +105,7 @@ #ifdef DEBUG_TIME_VALUE_LAYER cerr << "sf = " << sf << endl; #endif - sprintf(buffer, "%.*g", sf, dispval); + snprintf(buffer, buflen, "%.*g", sf, dispval); QString label = QString(buffer);