Commit b187a76a authored by Sean McBride's avatar Sean McBride Committed by Code Review

Merge topic 'even-more-clang-analzyer' into master

a5c4a9a7 Fixed memory leaks and malloc(0)
14c4790c Fixed null deref by returning upon error
e3337306 Fixed obvious dead stores
33dde16e Fixed null deref and whitespace/indentation
ba931533 Prevent null dereferences
845c2495 Remove a likely dead store
9d6d565c Suppress numerous warnings about using uninitialized memory
6fd5a5d5 Removed dead stores
2bacee00 Removed dead store to ‘j’
d00f6005 Init memory to prevent it being used uninitialized
53c18de6 Prevent null deref of ‘composite’ fn pointer
08852157 Prevent null deref of ‘null’
c5bacd4c Fixed incorrect indentation
parents 5e49cdcb a5c4a9a7
......@@ -582,6 +582,7 @@ void vtkLookupTable::SetTable(vtkUnsignedCharArray *table)
void vtkLookupTable::GetColorAsUnsignedChars(const double colorIn[4],
unsigned char colorOut[4])
{
assert(colorIn && colorOut);
if (!colorIn || !colorOut)
{
return;
......
......@@ -1398,20 +1398,17 @@ int vtkOrderedTriangulator::GetNextTetra(int classification, vtkTetra *tet,
vtkDataArray *cellScalars,
vtkDoubleArray *tetScalars)
{
OTTetra *tetra;
// Find the next tetra with the right classification
while ( this->Mesh->CurrentTetra != this->Mesh->Tetras.end() &&
(*this->Mesh->CurrentTetra)->Type != classification &&
(*this->Mesh->CurrentTetra)->Type != OTTetra::All )
{
tetra = *(this->Mesh->CurrentTetra);
++this->Mesh->CurrentTetra;
}
if ( this->Mesh->CurrentTetra != this->Mesh->Tetras.end() )
{
tetra = *(this->Mesh->CurrentTetra);
OTTetra *tetra = *(this->Mesh->CurrentTetra);
for (int i=0; i<4; i++)
{
tet->PointIds->SetId(i,tetra->Points[i]->Id);
......
......@@ -282,7 +282,7 @@ void vtkImageToPolyDataFilter::RunLengthImage(vtkUnsignedCharArray *pixels,
vtkCellArray *newPolys;
double x[3], minX, maxX, minY, maxY;
vtkUnsignedCharArray *polyColors;
unsigned char *ptr, *colors=pixels->GetPointer(0), *color;
unsigned char *colors=pixels->GetPointer(0), *color;
// Setup data
newPts = vtkPoints::New();
......@@ -324,10 +324,9 @@ void vtkImageToPolyDataFilter::RunLengthImage(vtkUnsignedCharArray *pixels,
minX = origin[0] + i*spacing[0] - 0.5*spacing[0];
}
color = colors + 3*(i+j*dims[0]);
ptr = color;
while ( i < dims[0] )
{
ptr = colors + 3*(i+j*dims[0]);
unsigned char *ptr = colors + 3*(i+j*dims[0]);
if ( ! this->IsSameColor(color,ptr) )
{
break;
......@@ -1221,8 +1220,8 @@ void vtkImageToPolyDataFilter::BuildPolygons(vtkUnsignedCharArray *vtkNotUsed(po
polyColors->SetValue(3*cellId+1, ptr[1]);
polyColors->SetValue(3*cellId+2, ptr[2]);
p1 = ptId; p2 = -1;
while ( 1 )
p1 = ptId;
while ( true )
{
edges->GetCellPoints(edgeId, npts, pts);
p2 = (pts[0] != p1 ? pts[0] : pts[1]);
......
......@@ -1056,7 +1056,6 @@ void vtkImplicitModeller::Cap(vtkDataArray *s)
int d01=this->SampleDimensions[0]*this->SampleDimensions[1];
// i-j planes
k = 0;
for (j=0; j<this->SampleDimensions[1]; j++)
{
for (i=0; i<this->SampleDimensions[0]; i++)
......@@ -1074,7 +1073,6 @@ void vtkImplicitModeller::Cap(vtkDataArray *s)
}
}
// j-k planes
i = 0;
for (k=0; k<this->SampleDimensions[2]; k++)
{
for (j=0; j<this->SampleDimensions[1]; j++)
......@@ -1091,7 +1089,6 @@ void vtkImplicitModeller::Cap(vtkDataArray *s)
}
}
// i-k planes
j = 0;
for (k=0; k<this->SampleDimensions[2]; k++)
{
for (i=0; i<this->SampleDimensions[0]; i++)
......
......@@ -144,15 +144,15 @@ int vtkTemporalSnapToTimeStep::RequestData(
if (inData && outData)
{
outData->ShallowCopy(inData);
}
// fill in the time steps
double inTime = inData->GetInformation()->Get(vtkDataObject::DATA_TIME_STEP());
// fill in the time steps
double inTime = inData->GetInformation()->Get(vtkDataObject::DATA_TIME_STEP());
if(inData->GetInformation()->Has(vtkDataObject::DATA_TIME_STEP()))
{
double outTime = inTime;
outData->GetInformation()->Set(vtkDataObject::DATA_TIME_STEP(), outTime);
if(inData->GetInformation()->Has(vtkDataObject::DATA_TIME_STEP()))
{
double outTime = inTime;
outData->GetInformation()->Set(vtkDataObject::DATA_TIME_STEP(), outTime);
}
}
return 1;
......
......@@ -401,17 +401,19 @@ int vtkWeightedTransformFilter::RequestData(
this->CellDataTransformIndexArray[0] != '\0')
{
fd = pd;
if(fd != NULL) {
cdtiArray = reinterpret_cast<vtkUnsignedShortArray *>
(fd->GetArray(this->CellDataTransformIndexArray));
}
if(cdtiArray == NULL)
if(fd != NULL)
{
fd = input->GetFieldData();
if(fd != NULL) {
cdtiArray = reinterpret_cast<vtkUnsignedShortArray *>
(fd->GetArray(this->CellDataTransformIndexArray));
}
if(cdtiArray == NULL)
{
fd = input->GetFieldData();
if(fd != NULL)
{
cdtiArray = reinterpret_cast<vtkUnsignedShortArray *>
(fd->GetArray(this->CellDataTransformIndexArray));
}
}
if(cdtiArray == NULL)
{
......@@ -430,7 +432,7 @@ int vtkWeightedTransformFilter::RequestData(
"CellDataWeightArray " << this->WeightArray);
cdtiArray = NULL;
}
if (cdtiArray->GetDataType() != VTK_UNSIGNED_SHORT)
if (cdtiArray && (cdtiArray->GetDataType() != VTK_UNSIGNED_SHORT))
{
vtkWarningMacro(<<"CellDataTransformIndexArray " <<
this->CellDataTransformIndexArray <<
......
......@@ -1095,12 +1095,12 @@ int vtkChacoReader::InputGraph2(
int end_flag = 1;
while (end_flag == 1)
{
j = this->ReadInt(fin, &end_flag);
this->ReadInt(fin, &end_flag);
++line_num;
}
while (!end_flag)
{
j = this->ReadInt(fin, &end_flag);
this->ReadInt(fin, &end_flag);
}
++line_num;
......
......@@ -3746,7 +3746,7 @@ void vtkFLUENTReader::PopulateWedgeCell(int i)
}
// Find the quad face with points 0 and 1 in them.
int w01[4];
int w01[4] = {-1, -1, -1, -1};
for (int j = 0; j < (int)this->Cells->value[i].faces.size(); j++)
{
if (this->Cells->value[i].faces[j] != base &&
......
......@@ -722,7 +722,11 @@ PlyFile *vtkPLY::ply_read(FILE *fp, int *nelems, char ***elem_names)
if (equal_strings (words[0], "format")) {
if (nwords != 3)
{
free (plyfile);
free (words);
return (NULL);
}
if (equal_strings (words[1], "ascii"))
plyfile->file_type = PLY_ASCII;
else if (equal_strings (words[1], "binary_big_endian"))
......@@ -731,6 +735,7 @@ PlyFile *vtkPLY::ply_read(FILE *fp, int *nelems, char ***elem_names)
plyfile->file_type = PLY_BINARY_LE;
else
{
free (plyfile);
free (words);
return (NULL);
}
......@@ -747,6 +752,7 @@ PlyFile *vtkPLY::ply_read(FILE *fp, int *nelems, char ***elem_names)
else if (equal_strings (words[0], "end_header"))
{
free (words);
words = NULL;
break;
}
......@@ -756,6 +762,12 @@ PlyFile *vtkPLY::ply_read(FILE *fp, int *nelems, char ***elem_names)
words = get_words (plyfile->fp, &nwords, &orig_line);
}
if (plyfile->nelems == 0)
{
free (plyfile);
free (words);
return (NULL);
}
/* create tags for each property of each element, to be used */
/* later to say whether or not to store each property for the user */
......
......@@ -880,6 +880,7 @@ void vtkImageBlend::ThreadedRequestData (
default:
vtkErrorMacro(<< "Execute: Unknown blending mode");
return;
}
// process each input
......
......@@ -2755,6 +2755,7 @@ void vtkGetRowCompositeFunc(
else { *composite = &(vtkImageResliceRowComp<F>::SumRow); }
break;
default:
vtkGenericWarningMacro("Illegal slab mode!");
*composite = 0;
}
}
......@@ -2854,7 +2855,7 @@ void vtkReslicePermuteExecute(vtkImageReslice *self,
scalarType, scalarSize, outComponents, outPtr);
// get the slab compositing function
void (*composite)(F *op, const F *ip, int nc, int count, int i, int n);
void (*composite)(F *op, const F *ip, int nc, int count, int i, int n) = 0;
vtkGetRowCompositeFunc(&composite,
self->GetSlabMode(), self->GetSlabTrapezoidIntegration());
......@@ -2931,7 +2932,7 @@ void vtkReslicePermuteExecute(vtkImageReslice *self,
interpolator->InterpolateRow(
weights, idX, idY, idZ1, tmpPtr, idXmax - idXmin + 1);
if (nsamples1 > 1)
if (composite && (nsamples1 > 1))
{
composite(floatPtr, floatSumPtr, inComponents,
idXmax - idXmin + 1, isample, nsamples1);
......
......@@ -126,34 +126,34 @@ double vtkFrustumCoverageCuller::Cull( vtkRenderer *ren,
planes[i*4 + 2] * center[2] +
planes[i*4 + 3];
// If d < -radius the prop is not within the view frustum
if ( d < -radius )
{
coverage = 0.0;
i = 7;
}
// The first four planes are the ones bounding the edges of the
// view plane (the last two are the near and far planes) The
// distance from the edge of the sphere to these planes is stored
// to compute coverage.
if ( i < 4 )
{
if ( d < -radius )
{
coverage = 0.0;
i = 7;
}
// The first four planes are the ones bounding the edges of the
// view plane (the last two are the near and far planes) The
// distance from the edge of the sphere to these planes is stored
// to compute coverage.
if ( i < 4 )
{
screen_bounds[i] = d - radius;
}
// The fifth plane is the near plane - use the distance to
// the center (d) as the value to sort by
if ( i == 4 )
{
distanceList[propLoop] = d;
}
}
// The fifth plane is the near plane - use the distance to
// the center (d) as the value to sort by
if ( i == 4 )
{
distanceList[propLoop] = d;
}
}
}
// If the prop wasn't culled during the plane tests...
if ( coverage > 0.0 )
{
{
// Compute the width and height of this slice through the
// view frustum that contains the center of the sphere
full_w = screen_bounds[0] + screen_bounds[1] + 2.0 * radius;
full_h = screen_bounds[2] + screen_bounds[3] + 2.0 * radius;
full_w = screen_bounds[0] + screen_bounds[1] + 2.0 * radius;
full_h = screen_bounds[2] + screen_bounds[3] + 2.0 * radius;
// Subtract from the full width to get the width of the square
// enclosing the circle slice from the sphere in the plane
// through the center of the sphere. If the screen bounds for
......
......@@ -265,11 +265,11 @@ unsigned long vtkRendererSource::GetMTime()
if (data)
{
mapper->GetInputAlgorithm()->UpdateInformation();
}
t2 = data->GetMTime();
if (t2 > t1)
{
t1 = t2;
t2 = data->GetMTime();
if (t2 > t1)
{
t1 = t2;
}
}
t2 = vtkDemandDrivenPipeline::SafeDownCast(
mapper->GetInputExecutive())->GetPipelineMTime();
......
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