Commit da4bc5da authored by Sean McBride's avatar Sean McBride Committed by Code Review
Browse files

Merge topic 'static-analysis2' into master

d8b8c823 Merged private function into destructor
43cb0292 Fixed division by zero found by cppcheck
9cee046a Check ResizeAndExtend error result and bail
e0c279f4 Fixed cppcheck warning about all-const params to strncmp
parents 9777e298 d8b8c823
......@@ -280,7 +280,10 @@ inline void vtkBitArray::InsertValue(vtkIdType id, int i)
{
if ( id >= this->Size )
{
this->ResizeAndExtend(id+1);
if (!this->ResizeAndExtend(id+1))
{
return;
}
}
if (i)
{
......
......@@ -152,7 +152,10 @@ inline vtkIdType vtkIdList::InsertNextId(const vtkIdType vtkid)
{
if ( this->NumberOfIds >= this->Size )
{
this->Resize(this->NumberOfIds+1);
if (!this->Resize(this->NumberOfIds+1))
{
return this->NumberOfIds-1;
}
}
this->Ids[this->NumberOfIds++] = vtkid;
return this->NumberOfIds-1;
......
......@@ -456,7 +456,10 @@ void vtkStringArray::InsertValue(vtkIdType id, vtkStdString f)
{
if ( id >= this->Size )
{
this->ResizeAndExtend(id+1);
if (!this->ResizeAndExtend(id+1))
{
return;
}
}
this->Array[id] = f;
if ( id > this->MaxId )
......
......@@ -639,7 +639,10 @@ void vtkVariantArray::InsertValue(vtkIdType id, vtkVariant value)
{
if ( id >= this->Size )
{
this->ResizeAndExtend(id+1);
if (!this->ResizeAndExtend(id+1))
{
return;
}
}
this->Array[id] = value;
if ( id > this->MaxId )
......
......@@ -98,7 +98,10 @@ void vtkVoidArray::InsertVoidPointer(vtkIdType id, void* p)
{
if ( id >= this->Size )
{
this->ResizeAndExtend(id+1);
if (!this->ResizeAndExtend(id+1))
{
return;
}
}
this->Array[id] = p;
if ( id >= this->NumberOfPointers )
......
......@@ -661,16 +661,14 @@ void vtkPDataSetReader::ReadVTKFileInformation(
vtkInformation* info = outputVector->GetInformationObject(0);
// To avoid UMR in the first string comparison
strcpy(str, " ");
// Try to find the line that specifies the dataset type.
i = 0;
while (strncmp(str, "DATASET", 7) != 0 && i < 6)
do
{
file->getline(str, 1024);
++i;
}
while (strncmp(str, "DATASET", 7) != 0 && i < 6);
if (strncmp(str, "DATASET POLYDATA", 16) == 0)
{
......
......@@ -208,16 +208,21 @@ void vtkImageMapToWindowLevelClamps ( vtkImageData *data, double w,
}
// now compute the lower and upper values
if (w >= 0)
if (w > 0.0)
{
f_lower_val = 255.0*(adjustedLower - f_lower)/w;
f_upper_val = 255.0*(adjustedUpper - f_lower)/w;
}
else
else if (w < 0.0)
{
f_lower_val = 255.0 + 255.0*(adjustedLower - f_lower)/w;
f_upper_val = 255.0 + 255.0*(adjustedUpper - f_lower)/w;
}
else
{
f_lower_val = 0.0;
f_upper_val = 255.0;
}
if (f_upper_val > 255)
{
......
......@@ -185,7 +185,7 @@ public:
~vtkHAVSScalarHistogram()
{
this->Cleanup();
if (this->ScalarTable) { delete [] ScalarTable; }
}
void DefineBuckets(unsigned int nBuckets)
......@@ -227,12 +227,6 @@ public:
}
return max;
}
void Cleanup()
{
if (this->ScalarTable) { delete [] ScalarTable; }
this->ScalarTable = NULL;
}
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment