Skip to content

Fix leaks from vtkParsePreprocess.c

Mmanu Chaturvedi requested to merge m-chaturvedi/vtk:LSan_vtkParseProcess into master

Leaks similar to this:

Direct leak of 8008 byte(s) in 143 object(s) allocated from:
    #0 0x40c11f in __interceptor_malloc (/home/chaturvedi/workspace/vtk/vtk/cmake-build-debug/bin/vtkWrapHierarchy-9.0+0x40c11f)
    #1 0x45dc32 in preproc_new_macro /home/chaturvedi/workspace/vtk/vtk/cmake-build-debug/../Wrapping/Tools/vtkParsePreprocess.c:140:35
    #2 0x45d72b in preproc_add_macro_definition /home/chaturvedi/workspace/vtk/vtk/cmake-build-debug/../Wrapping/Tools/vtkParsePreprocess.c:333:11
    #3 0x45bbce in vtkParsePreprocess_AddStandardMacros /home/chaturvedi/workspace/vtk/vtk/cmake-build-debug/../Wrapping/Tools/vtkParsePreprocess.c:3207:5
    #4 0x4461c0 in vtkParse_ParseFile /home/chaturvedi/workspace/vtk/vtk/cmake-build-debug/../Wrapping/Tools/vtkParse.tab.c:12278:3
    #5 0x433896 in vtkWrapHierarchy_ParseHeaderFile /home/chaturvedi/workspace/vtk/vtk/cmake-build-debug/../Wrapping/Tools/vtkWrapHierarchy.c:580:10
    #6 0x43329f in vtkWrapHierarchy_TryParseHeaderFile /home/chaturvedi/workspace/vtk/vtk/cmake-build-debug/../Wrapping/Tools/vtkWrapHierarchy.c:812:11
    #7 0x43302c in main /home/chaturvedi/workspace/vtk/vtk/cmake-build-debug/../Wrapping/Tools/vtkWrapHierarchy.c:971:13
    #8 0x7f59aa88082f in __libc_start_main /build/glibc-bfm8X4/glibc-2.23/csu/../csu/libc-start.c:291

The leakage is due to two allocations and only one freeing.

All the repetitions can be found by using this script on the appropriate code. To reproduce, build with LSan.

Merge request reports