Skip to content

Commit

Permalink
Merge topic 'asan-fixes'
Browse files Browse the repository at this point in the history
0bf793f vtkDataSetSurfaceFilter: fix reset of `OriginalCellIds`
245f211 vtkVoxelContoursToSurfaceFilter: no-op without a length
c43e57d vtkAbstractTransform: fix vtkSimpleTransform inheritance
023bf77 vtkXMLP*Reader: do not allocate for empty piece counts
aa89d0b VPICGlobal: plug memory leaks
9f77b41 TestAngleWidget*D: use anonymous namespaces
8699678 vtkTGAReader: add missing `PrintSelf` method
01da9c7 vtkSimpleScalarTree: remove unnecessary guard for `delete[]`
...

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: David Gobbi <david.gobbi@gmail.com>
Acked-by: Sean McBride <sean@rogue-research.com>
Acked-by: Cory Quammen <cory.quammen@kitware.com>
Merge-request: !8519
  • Loading branch information
mathstuf authored and kwrobot committed Oct 14, 2021
2 parents 15b1667 + 0bf793f commit 461c979
Show file tree
Hide file tree
Showing 48 changed files with 152 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Common/Core/Testing/Cxx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ vtk_add_test_cxx(vtkCommonCoreCxxTests tests
add_executable(TestLoggerDisableSignalHandlerCxx
TestLoggerDisableSignalHandler.cxx)
target_link_libraries(TestLoggerDisableSignalHandlerCxx
PRIVATE VTK::CommonCore)
PRIVATE VTK::CommonCore VTK::CommonDataModel)
add_test(NAME TestLoggerDisableSignalHandler
COMMAND ${CMAKE_COMMAND}
-DEXECUTABLE_PATH:FILEPATH=$<TARGET_FILE:TestLoggerDisableSignalHandlerCxx>
Expand Down
1 change: 1 addition & 0 deletions Common/Core/vtkRandomPool.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ const double* vtkRandomPool::GeneratePool()
this->NumberOfComponents = 1;
}
this->ChunkSize = (this->ChunkSize < 1000 ? 1000 : this->ChunkSize);
delete[] this->Pool;
this->Pool = new double[this->TotalSize];

// Control the number of threads spawned.
Expand Down
8 changes: 3 additions & 5 deletions Common/ExecutionModel/vtkSimpleScalarTree.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ vtkSimpleScalarTree::vtkSimpleScalarTree()
vtkSimpleScalarTree::~vtkSimpleScalarTree()
{
delete[] this->Tree;
delete[] this->CandidateCells;
}

//------------------------------------------------------------------------------
Expand Down Expand Up @@ -394,11 +395,8 @@ vtkIdType vtkSimpleScalarTree::GetNumberOfCellBatches(double scalarValue)
// Basically we do a traversal of the tree and identify potential candidates.
// It is essential that InitTraversal() has been called first.
this->NumCandidates = 0;
if (this->CandidateCells)
{
delete[] this->CandidateCells;
this->CandidateCells = nullptr;
}
delete[] this->CandidateCells;
this->CandidateCells = nullptr;
if (this->NumCells < 1)
{
return 0;
Expand Down
1 change: 1 addition & 0 deletions Common/Math/vtk.module
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ DEPENDS
VTK::CommonCore
VTK::kissfft
TEST_DEPENDS
VTK::CommonDataModel
VTK::CommonSystem
VTK::CommonTransforms
VTK::TestingCore
1 change: 1 addition & 0 deletions Common/Misc/vtk.module
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ PRIVATE_DEPENDS
VTK::vtksys
VTK::exprtk
TEST_DEPENDS
VTK::CommonDataModel
VTK::TestingCore
1 change: 1 addition & 0 deletions Common/System/vtk.module
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ DEPENDS
PRIVATE_DEPENDS
VTK::vtksys
TEST_DEPENDS
VTK::CommonDataModel
VTK::TestingCore
6 changes: 3 additions & 3 deletions Common/Transforms/vtkAbstractTransform.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "vtkDataArray.h"
#include "vtkDebugLeaks.h"
#include "vtkHomogeneousTransform.h"
#include "vtkLinearTransform.h"
#include "vtkMath.h"
#include "vtkMatrix4x4.h"
#include "vtkObjectFactory.h"
Expand Down Expand Up @@ -351,10 +351,10 @@ void vtkAbstractTransform::UnRegister(vtkObjectBase* o)

//------------------------------------------------------------------------------
// A very, very minimal transformation
class vtkSimpleTransform : public vtkHomogeneousTransform
class vtkSimpleTransform : public vtkLinearTransform
{
public:
vtkTypeMacro(vtkSimpleTransform, vtkHomogeneousTransform);
vtkTypeMacro(vtkSimpleTransform, vtkLinearTransform);
static vtkSimpleTransform* New() { VTK_STANDARD_NEW_BODY(vtkSimpleTransform); }
vtkAbstractTransform* MakeTransform() override { return vtkSimpleTransform::New(); }
void Inverse() override
Expand Down
4 changes: 2 additions & 2 deletions Examples/Modules/UsingVTK/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}"
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")

# We just need the CommonCore module here.
find_package(VTK COMPONENTS CommonCore)
find_package(VTK COMPONENTS CommonCore CommonDataModel)
if (NOT VTK_FOUND)
message("Skipping example: ${VTK_NOT_FOUND_MESSAGE}")
return ()
Expand All @@ -17,7 +17,7 @@ include(CTest)

add_library(vtk_using_lib uses_vtk.cxx)
# VTK modules act just like CMake imported targets.
target_link_libraries(vtk_using_lib PRIVATE VTK::CommonCore)
target_link_libraries(vtk_using_lib PRIVATE VTK::CommonCore VTK::CommonDataModel)
target_include_directories(vtk_using_lib PUBLIC "${CMAKE_CURRENT_BINARY_DIR}")
include(GenerateExportHeader)
generate_export_header(vtk_using_lib)
Expand Down
2 changes: 1 addition & 1 deletion Filters/Core/vtkProbeFilter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ namespace
// Thread local storage
struct ProbeImageDataPointsThreadLocal
{
bool BaseThread;
bool BaseThread = false;
vtkSmartPointer<vtkIdList> PointIds;
};

Expand Down
1 change: 1 addition & 0 deletions Filters/Extraction/vtkExtractBlockUsingDataAssembly.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ vtkExtractBlockUsingDataAssembly::vtkExtractBlockUsingDataAssembly()
vtkExtractBlockUsingDataAssembly::~vtkExtractBlockUsingDataAssembly()
{
delete this->Internals;
delete[] this->AssemblyName;
}

//------------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions Filters/General/vtkAnimateModes.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ vtkAnimateModes::vtkAnimateModes()
, ModeShapesRange{ 1, 1 }
, ModeShape{ 1 }
, DisplacementMagnitude{ 1.0 }
, DisplacementPreapplied(false)
, TimeRange{ 0.0, 1.0 }
{
// the displacement array
Expand Down
8 changes: 7 additions & 1 deletion Filters/General/vtkMergeVectorComponents.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ vtkMergeVectorComponents::vtkMergeVectorComponents()
}

//------------------------------------------------------------------------------
vtkMergeVectorComponents::~vtkMergeVectorComponents() = default;
vtkMergeVectorComponents::~vtkMergeVectorComponents()
{
this->SetXArrayName(nullptr);
this->SetYArrayName(nullptr);
this->SetZArrayName(nullptr);
this->SetOutputVectorName(nullptr);
}

//------------------------------------------------------------------------------
int vtkMergeVectorComponents::FillInputPortInformation(int vtkNotUsed(port), vtkInformation* info)
Expand Down
5 changes: 5 additions & 0 deletions Filters/General/vtkVoxelContoursToSurfaceFilter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ void vtkVoxelContoursToSurfaceFilter::SortLineList()
double tmp[4];
double tmpval;

if (!this->LineListLength)
{
return;
}

// Make sure we have enough space in our sorted list
if (this->SortedListSize < this->LineListLength)
{
Expand Down
18 changes: 17 additions & 1 deletion Filters/Geometry/vtkDataSetSurfaceFilter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,16 @@ vtkDataSetSurfaceFilter::~vtkDataSetSurfaceFilter()
{
this->SetOriginalCellIdsName(nullptr);
this->SetOriginalPointIdsName(nullptr);
if (this->OriginalPointIds)
{
this->OriginalPointIds->Delete();
this->OriginalPointIds = nullptr;
}
if (this->OriginalCellIds)
{
this->OriginalCellIds->Delete();
this->OriginalCellIds = nullptr;
}
}

//------------------------------------------------------------------------------
Expand Down Expand Up @@ -603,7 +613,7 @@ int vtkDataSetSurfaceFilter::UniformGridExecute(
if (this->OriginalCellIds)
{
this->OriginalCellIds->Delete();
this->OriginalPointIds = nullptr;
this->OriginalCellIds = nullptr;
}
return 1;
}
Expand Down Expand Up @@ -1303,9 +1313,11 @@ int vtkDataSetSurfaceFilter::UnstructuredGridExecute(
// Depending on the outcome, we may process the data ourselves, or send over
// to the faster vtkGeometryFilter.
bool mayDelegate = (info == nullptr && this->Delegation);
bool info_owned = false;
if (info == nullptr)
{
info = vtkGeometryFilterHelper::CharacterizeUnstructuredGrid(input);
info_owned = true;
}
bool handleSubdivision = (!info->IsLinear);

Expand All @@ -1319,6 +1331,10 @@ int vtkDataSetSurfaceFilter::UnstructuredGridExecute(
delete info;
return 1;
}
if (info_owned)
{
delete info;
}

// If here, the data is gnarly and this filter will process it.
vtkSmartPointer<vtkCellIterator> cellIter =
Expand Down
8 changes: 8 additions & 0 deletions Filters/Geometry/vtkGeometryFilter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ vtkGeometryFilter::vtkGeometryFilter()
vtkGeometryFilter::~vtkGeometryFilter()
{
this->SetLocator(nullptr);
this->SetOriginalCellIdsName(nullptr);
this->SetOriginalPointIdsName(nullptr);
}

//------------------------------------------------------------------------------
Expand Down Expand Up @@ -2090,9 +2092,11 @@ int vtkGeometryFilter::UnstructuredGridExecute(vtkDataSet* dataSetInput, vtkPoly
// Depending on the outcome, we may process the data ourselves, or send over
// to the faster vtkGeometryFilter.
bool mayDelegate = (info == nullptr && this->Delegation);
bool info_owned = false;
if (info == nullptr)
{
info = vtkGeometryFilterHelper::CharacterizeUnstructuredGrid(input);
info_owned = true;
}

// Nonlinear cells are handled by vtkDataSetSurfaceFilter
Expand All @@ -2105,6 +2109,10 @@ int vtkGeometryFilter::UnstructuredGridExecute(vtkDataSet* dataSetInput, vtkPoly
delete info;
return 1;
}
if (info_owned)
{
delete info;
}

auto cellIter = vtk::TakeSmartPointer(input->NewCellIterator());
vtkIdType cellId;
Expand Down
1 change: 1 addition & 0 deletions Filters/Modeling/vtkTrimmedExtrusionFilter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ int vtkTrimmedExtrusionFilter::RequestData(vtkInformation* vtkNotUsed(request),
{
this->AdjustPoints(input, numPts, numCells, hits, newPts);
}
delete[] hits;

// Now generate the topology.
this->ExtrudeEdges(input, output, numPts, numCells);
Expand Down
1 change: 1 addition & 0 deletions Filters/Parallel/Testing/Cxx/PTextureMapToSphere.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ void MyProcess::Execute()
vtkNew<vtkPNGReader> PNGReader;
PNGReader->SetFileName(fname);
PNGReader->Update();
delete[] fname;

vtkNew<vtkTexture> texture;
texture->SetInputConnection(PNGReader->GetOutputPort());
Expand Down
2 changes: 2 additions & 0 deletions Filters/ParallelFlowPaths/Testing/Cxx/TestPStreamAMR.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ int TestPStreamAMR(int argc, char* argv[])
imageSource->SetCellArrayStatus("y-velocity", 1);
imageSource->SetCellArrayStatus("z-velocity", 1);

delete[] fname;

vtkNew<TestAMRVectorSource> gradientSource;
gradientSource->SetInputConnection(imageSource->GetOutputPort());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class MessageStream
MessageStream& operator>>(T& t)
{
size_t size = sizeof(T);
t = *reinterpret_cast<T*>(this->Head);
memcpy(&t, this->Head, size);
this->Head += size;
return *this;
}
Expand Down
2 changes: 1 addition & 1 deletion Filters/ParallelFlowPaths/vtkPStreamTracer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class MyStream
{
unsigned int size = sizeof(T);
AssertGe(Size, this->Head + size - this->Data);
t = *(reinterpret_cast<T*>(this->Head));
memcpy(&t, this->Head, sizeof(T));
this->Head += size;
return (*this);
}
Expand Down
5 changes: 5 additions & 0 deletions Filters/ParallelGeometry/vtkPDistributedDataFilter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1419,6 +1419,11 @@ vtkFloatArray** vtkPDistributedDataFilter::ExchangeFloatArraysLean(
{
vtkErrorMacro(<< "vtkPDistributedDataFilter::ExchangeIdArrays memory allocation");
delete[] recvSize;
delete[] sendSize;
for (int i = 0; i < nprocs; ++i)
{
delete[] recvArrays[i];
}
delete[] recvArrays;
return nullptr;
}
Expand Down
8 changes: 8 additions & 0 deletions Filters/ParallelStatistics/vtkPOrderStatistics.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -293,19 +293,26 @@ void vtkPOrderStatistics::Learn(
if (!com->GatherV(&(*sPack_l.begin()), sPack_g, nc_l, nc_g, offsets, rProc))
{
vtkErrorMacro("Process " << myRank << "could not gather string values.");
delete[] nc_g;
delete[] offsets;
delete[] sPack_g;

return;
}
delete[] nc_g;
delete[] offsets;

// Reduce to global histogram on process rProc
std::map<vtkStdString, vtkIdType> histogram;
if (myRank == rProc)
{
if (this->Reduce(card_g, ncTotal, sPack_g, histogram))
{
delete[] sPack_g;
return;
}
} // if ( myRank == rProc )
delete[] sPack_g;

// Create column for global histogram values of the same type as the values
vtkStringArray* sVals_g = vtkStringArray::New();
Expand All @@ -316,6 +323,7 @@ void vtkPOrderStatistics::Learn(
{
vtkErrorMacro("Process " << com->GetLocalProcessId()
<< " could not broadcast reduced histogram values.");
sVals_g->Delete();

return;
}
Expand Down
5 changes: 5 additions & 0 deletions IO/ADIOS2/vtkADIOS2VTXReader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ vtkADIOS2VTXReader::vtkADIOS2VTXReader()
this->SetNumberOfOutputPorts(1);
}

vtkADIOS2VTXReader::~vtkADIOS2VTXReader()
{
this->SetFileName(nullptr);
}

int vtkADIOS2VTXReader::RequestInformation(vtkInformation* vtkNotUsed(inputVector),
vtkInformationVector** vtkNotUsed(inputVector), vtkInformationVector* outputVector)
{
Expand Down
2 changes: 1 addition & 1 deletion IO/ADIOS2/vtkADIOS2VTXReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class VTKIOADIOS2_EXPORT vtkADIOS2VTXReader : public vtkMultiBlockDataSetAlgorit

protected:
vtkADIOS2VTXReader();
~vtkADIOS2VTXReader() = default;
~vtkADIOS2VTXReader();

vtkADIOS2VTXReader(const vtkADIOS2VTXReader&) = delete;
void operator=(const vtkADIOS2VTXReader&) = delete;
Expand Down
4 changes: 3 additions & 1 deletion IO/Image/Testing/Cxx/TestSEPReader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@

int TestSEPReader(int argc, char* argv[])
{
const std::string filename = vtkTestUtilities::ExpandDataFileName(argc, argv, "Data/small.H");
char* fname = vtkTestUtilities::ExpandDataFileName(argc, argv, "Data/small.H");
const std::string filename = fname;
delete[] fname;

vtkNew<vtkSEPReader> SEPReader;

Expand Down
1 change: 1 addition & 0 deletions IO/Image/vtkJSONImageWriter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ vtkJSONImageWriter::vtkJSONImageWriter()
vtkJSONImageWriter::~vtkJSONImageWriter()
{
this->SetFileName(nullptr);
this->SetArrayName(nullptr);
}

//------------------------------------------------------------------------------
Expand Down
6 changes: 6 additions & 0 deletions IO/Image/vtkTGAReader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,9 @@ int vtkTGAReader::CanReadFile(const char* fname)

return 1;
}

//------------------------------------------------------------------------------
void vtkTGAReader::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
}
1 change: 1 addition & 0 deletions IO/Image/vtkTGAReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class VTKIOIMAGE_EXPORT vtkTGAReader : public vtkImageReader2
public:
static vtkTGAReader* New();
vtkTypeMacro(vtkTGAReader, vtkImageReader2);
void PrintSelf(ostream& os, vtkIndent indent) override;

/**
* Is the given file a valid TGA file?
Expand Down
1 change: 1 addition & 0 deletions IO/MPIParallel/vtkMPIMultiBlockPLOT3DReader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ void vtkMPIMultiBlockPLOT3DReader::CloseFile(void* vfp)
{
vtkErrorMacro("Failed to close file!");
}
delete handle;
}

//------------------------------------------------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions IO/PIO/PIOAdaptor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ void BroadcastDoubleVector(
///////////////////////////////////////////////////////////////////////////////

PIOAdaptor::PIOAdaptor(vtkMultiProcessController* ctrl)
: useHTG(false)
, useTracer(false)
, useFloat64(false)
, hasTracers(false)
{
this->Controller = ctrl;
if (this->Controller)
Expand Down
Loading

0 comments on commit 461c979

Please sign in to comment.