Mercurial > hg > svgui
comparison 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 |
comparison
equal
deleted
inserted
replaced
863:7c75fae51409 | 864:3ca3b8fbbcee |
---|---|
53 | 53 |
54 #ifdef DEBUG_TIME_VALUE_LAYER | 54 #ifdef DEBUG_TIME_VALUE_LAYER |
55 cerr << "min = " << minlog << ", max = " << maxlog << ", inc = " << inc << ", minDispInc = " << minDispInc << endl; | 55 cerr << "min = " << minlog << ", max = " << maxlog << ", inc = " << inc << ", minDispInc = " << minDispInc << endl; |
56 #endif | 56 #endif |
57 | 57 |
58 char buffer[40]; | 58 const int buflen = 40; |
59 char buffer[buflen]; | |
59 | 60 |
60 float round = 1.f; | 61 float round = 1.f; |
61 int dp = 0; | 62 int dp = 0; |
62 | 63 |
63 if (minDispInc > 0) { | 64 if (minDispInc > 0) { |
102 int sf = dp + (digits > 0 ? digits : 0); | 103 int sf = dp + (digits > 0 ? digits : 0); |
103 if (sf < 4) sf = 4; | 104 if (sf < 4) sf = 4; |
104 #ifdef DEBUG_TIME_VALUE_LAYER | 105 #ifdef DEBUG_TIME_VALUE_LAYER |
105 cerr << "sf = " << sf << endl; | 106 cerr << "sf = " << sf << endl; |
106 #endif | 107 #endif |
107 sprintf(buffer, "%.*g", sf, dispval); | 108 snprintf(buffer, buflen, "%.*g", sf, dispval); |
108 | 109 |
109 QString label = QString(buffer); | 110 QString label = QString(buffer); |
110 | 111 |
111 paint.drawLine(w - 5, y, w, y); | 112 paint.drawLine(w - 5, y, w, y); |
112 | 113 |