Mercurial > hg > svgui
diff layer/Colour3DPlotLayer.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 | db0759e4c6c3 |
children | a1226b3b7925 |
line wrap: on
line diff
--- a/layer/Colour3DPlotLayer.cpp Fri Sep 12 11:50:26 2014 +0100 +++ b/layer/Colour3DPlotLayer.cpp Mon Sep 29 13:27:13 2014 +0100 @@ -1331,7 +1331,9 @@ QPoint illuminatePos; bool illuminate = v->shouldIlluminateLocalFeatures(this, illuminatePos); - char labelbuf[10]; + + const int buflen = 40; + char labelbuf[buflen]; for (int sx = sx0; sx <= sx1; ++sx) { @@ -1395,7 +1397,7 @@ if (sx >= 0 && sx < m_cache->width() && sy >= 0 && sy < m_cache->height()) { float value = m_model->getValueAt(sx, sy); - sprintf(labelbuf, "%06f", value); + snprintf(labelbuf, buflen, "%06f", value); QString text(labelbuf); paint.setPen(v->getBackground()); paint.drawText(rx0 + 2,