Deallocation of an auto-variable results in undefined behaviour." verbose="The deallocation of an auto-variable results in undefined behaviour. You should only free memory that has been allocated dynamically
and if i use this , it works fine -
custom_data_deallocator(ptr);
However, this is clearly wrong (i am just testing cppheck without compilation) as my deallocator function expects a double pointer.
Here is my .cfg snippet -
<memory>
<alloc>custom_data_allocator</alloc>
<dealloc>custom_data_deallocator</dealloc>
</memory>
Please let me know if am missing anything. Also, these alloc/dealloc functions are third party.
Thanks
Siddharth
Last edit: Siddharth 2019-02-01
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have this code here -
custom_data_type *ptr;
ptr = custom_data_allocator();
custom_data_deallocator(&ptr);
However, cppcheck complains -
Deallocation of an auto-variable results in undefined behaviour." verbose="The deallocation of an auto-variable results in undefined behaviour. You should only free memory that has been allocated dynamically
and if i use this , it works fine -
custom_data_deallocator(ptr);
However, this is clearly wrong (i am just testing cppheck without compilation) as my deallocator function expects a double pointer.
Here is my .cfg snippet -
<memory>
<alloc>custom_data_allocator</alloc>
<dealloc>custom_data_deallocator</dealloc>
</memory>
Please let me know if am missing anything. Also, these alloc/dealloc functions are third party.
Thanks
Siddharth
Last edit: Siddharth 2019-02-01
Can you please try this configuration, I don't know maybe that works: