[vtk-developers] Fwd: New Defects reported by Coverity Scan for VTK

David Lonie david.lonie at kitware.com
Mon May 16 11:23:54 EDT 2016


On Mon, May 16, 2016 at 10:10 AM, Ken Martin <ken.martin at kitware.com> wrote:

> 894           in1 = src1DA->GetComponent(srcTuple1, c);
> >>>     CID 1355146:  Null pointer dereferences  (NULL_RETURNS)
> >>>     Dereferencing a pointer that might be null "src2DA" when calling
> "GetComponent". (The dereference happens because this is a virtual function
> call.)
>

This actually has a NULL check, but there's a missing return statement.
I'll fix this up.


> *** CID 1355147:  Resource leaks  (RESOURCE_LEAK)
> /home/nschloe/software/vtk/source-upstream/IO/XML/Testing/Cxx/TestXMLWriterWithDataArrayFallback.cxx:
> 32 in TestXMLWriterWithDataArrayFallback(int, char **)()
> 26     #include "vtkXMLImageDataWriter.h"
> 27
> 28     #include <string>
> 29
> 30     int TestXMLWriterWithDataArrayFallback(int argc, char *argv[])
> 31     {
> >>>     CID 1355147:  Resource leaks  (RESOURCE_LEAK)
> >>>     Failing to save or free storage allocated by
> "vtkTestUtilities::GetArgOrEnvOrDefault("-T", argc, argv, "VTK_TEMP_DIR",
> "Testing/Temporary")" leaks it.
> 32       std::string temp_dir =
> std::string(vtkTestUtilities::GetArgOrEnvOrDefault(
> 33                                            "-T", argc, argv,
> "VTK_TEMP_DIR",
> 34                                            "Testing/Temporary"));
>

Pinging TJ -- I'm guessing that the string returned from
vtkTestUtilities::GetArgOrEnvOrDefault needs to be deleted explicitly by
the caller.



> ** CID 1355148:  Null pointer dereferences  (REVERSE_INULL)
> /home/nschloe/software/vtk/source-upstream/Common/Core/vtkDataArray.cxx:
> 1310 in vtkDataArray::CreateDataArray(int)()
>
>
>
> ________________________________________________________________________________________________________
> *** CID 1355148:  Null pointer dereferences  (REVERSE_INULL)
> /home/nschloe/software/vtk/source-upstream/Common/Core/vtkDataArray.cxx:
> 1310 in vtkDataArray::CreateDataArray(int)()
> 1304
> 1305
>  //----------------------------------------------------------------------------
> 1306     vtkDataArray* vtkDataArray::CreateDataArray(int dataType)
> 1307     {
> 1308       vtkAbstractArray* aa = vtkAbstractArray::CreateArray(dataType);
> 1309       vtkDataArray* da = vtkDataArray::FastDownCast(aa);
> >>>     CID 1355148:  Null pointer dereferences  (REVERSE_INULL)
> >>>     Null-checking "aa" suggests that it may be null, but it has
> already been dereferenced on all paths leading to the check.
> 1310       if (!da && aa)
> 1311         {
> 1312         // Requested array is not a vtkDataArray. Delete the
> allocated array.
> 1313         aa->Delete();
> 1314         }
> 1315       return da;
>

This has been fixed since the coverty scan last ran -- FastDownCast will
NULL check its argument after d97bea99f (just merged last week).

Dave
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20160516/83e83275/attachment-0001.html>


More information about the vtk-developers mailing list