Skip to content

Commit f939696

Browse files
committed
fix comparison
would have overrun vspaces_, if numLabels_ equals 0
1 parent 55e2355 commit f939696

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/OpenCOVER/PluginUtil/coColorBar.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static void calcFormat(float &minIO, float &maxIO, char * /*mask*/, int &iSteps)
4646
double min = minIO;
4747
double max = maxIO;
4848
bool swapped = false;
49-
if (min > max)
49+
if (min > max)
5050
{
5151
swapped = true;
5252
std::swap(min, max);
@@ -101,7 +101,7 @@ static void calcFormat(float &minIO, float &maxIO, char * /*mask*/, int &iSteps)
101101
}
102102
else
103103
{
104-
104+
105105
/// negative digits - may require exponetials
106106
double maxAbs = fabs(max);
107107
double minAbs = fabs(min);
@@ -296,7 +296,7 @@ coColorBar::update(const ColorMap &map)
296296
makeLabelValues(map);
297297
float vgap = (Height - (numLabels_-1)*LabelHeight)/(numLabels_-1);
298298

299-
for (size_t i = 0; i < numLabels_; i++)
299+
for (int i = 0; i < numLabels_; i++)
300300
{
301301
snprintf(str+off, sizeof(str)-off, format_str_, labelValues_[i]);
302302
if (str[off] == '-')
@@ -322,7 +322,7 @@ coColorBar::update(const ColorMap &map)
322322
labels_[i]->setString(str+off);
323323
}
324324
allLabels_->addElement(labelAndHspaces_[i]);
325-
if (i < numLabels_-1)
325+
if (i+1 < numLabels_)
326326
{
327327
vspaces_[i]->setMinHeight(vgap);
328328
allLabels_->addElement(vspaces_[i]);

0 commit comments

Comments
 (0)