Mercurial > hg > svgui
diff layer/LogColourScale.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 | b66fb15de477 |
line wrap: on
line diff
--- a/layer/LogColourScale.cpp Fri Sep 12 11:50:26 2014 +0100 +++ b/layer/LogColourScale.cpp Mon Sep 29 13:27:13 2014 +0100 @@ -46,7 +46,8 @@ float val = minlog; float inc = (maxlog - val) / n; - char buffer[40]; + const int buflen = 40; + char buffer[buflen]; int boxx = 5, boxy = 5; if (layer->getScaleUnits() != "") { @@ -85,7 +86,7 @@ int digits = trunc(log10f(dv)); int sf = dp + (digits > 0 ? digits : 0); if (sf < 2) sf = 2; - sprintf(buffer, "%.*g", sf, dv); + snprintf(buffer, buflen, "%.*g", sf, dv); QString label = QString(buffer);