Leak in vtkInformation*Key::MakeKey Python wrapping
I'm seeing this from clang-tidy
:
/build/build/CMakeFiles/vtkCommonExecutionModelPython/vtkInformationDataObjectMetaDataKeyPython.cxx:202:10: warning: Potential leak of memory pointed to by 'tempr' [clang-analyzer-cplusplus.NewDeleteLeaks]
return result;
^
/build/build/CMakeFiles/vtkCommonExecutionModelPython/vtkInformationDataObjectMetaDataKeyPython.cxx:185:7: note: Left side of '&&' is true
if (ap.CheckArgCount(2) &&
^
/build/build/CMakeFiles/vtkCommonExecutionModelPython/vtkInformationDataObjectMetaDataKeyPython.cxx:186:7: note: Assuming the condition is true
ap.GetValue(temp0) &&
^
/build/build/CMakeFiles/vtkCommonExecutionModelPython/vtkInformationDataObjectMetaDataKeyPython.cxx:185:7: note: Left side of '&&' is true
if (ap.CheckArgCount(2) &&
^
/build/build/CMakeFiles/vtkCommonExecutionModelPython/vtkInformationDataObjectMetaDataKeyPython.cxx:187:7: note: Assuming the condition is true
ap.GetValue(temp1))
^
/build/build/CMakeFiles/vtkCommonExecutionModelPython/vtkInformationDataObjectMetaDataKeyPython.cxx:185:3: note: Taking true branch
if (ap.CheckArgCount(2) &&
^
/build/build/CMakeFiles/vtkCommonExecutionModelPython/vtkInformationDataObjectMetaDataKeyPython.cxx:189:50: note: Calling 'vtkInformationDataObjectMetaDataKey::MakeKey'
vtkInformationDataObjectMetaDataKey *tempr = vtkInformationDataObjectMetaDataKey::MakeKey(temp0, temp1);
^
/build/src/VTK/Common/ExecutionModel/vtkInformationDataObjectMetaDataKey.h:49:12: note: Memory is allocated
return new vtkInformationDataObjectMetaDataKey(name, location);
^
/build/build/CMakeFiles/vtkCommonExecutionModelPython/vtkInformationDataObjectMetaDataKeyPython.cxx:189:50: note: Returned allocated memory
vtkInformationDataObjectMetaDataKey *tempr = vtkInformationDataObjectMetaDataKey::MakeKey(temp0, temp1);
^
/build/build/CMakeFiles/vtkCommonExecutionModelPython/vtkInformationDataObjectMetaDataKeyPython.cxx:191:5: note: Taking false branch
if (!ap.ErrorOccurred())
^
/build/build/CMakeFiles/vtkCommonExecutionModelPython/vtkInformationDataObjectMetaDataKeyPython.cxx:202:10: note: Potential leak of memory pointed to by 'tempr'
return result;
^
And it is indeed true that if ap.ErrorOccurred()
, the MakeKey
return value is leaked. It needs a delete
if that's not the case.
I tried using VTK_NEWINSTANCE
, but that didn't work.