which, when tested with cppcheck 2.9 gets the error on last line of the function
Fsb.c:2259:1: error: Memory leak: data [memleak]
Apparently the data is allocated in the function, but not freed, as it is passed on as parameter to XtAddCallback().
So "data" must not be freed, as it will be used in the future as a parameter of the callback.
I call cppcheck with the following options
--library=motif.cfg --platform=unix64 --std=c99 --enable=all
The motif.cfg contains an entry for XtAddCallback:
<function name="XtAddCallback">
<leak-ignore>
<returnvalue type="void">
<arg nr="1">
<not-uninit>
</not-uninit></arg>
<arg nr="2">
<not-uninit>
</not-uninit></arg>
<arg nr="4">
</arg></returnvalue></leak-ignore></function>
So I am not sure if false positive is caused by bad definition in motif.cfg or by cppcheck itself.
I have the following code
which, when tested with cppcheck 2.9 gets the error on last line of the function
Fsb.c:2259:1: error: Memory leak: data [memleak]
Apparently the data is allocated in the function, but not freed, as it is passed on as parameter to XtAddCallback().
So "data" must not be freed, as it will be used in the future as a parameter of the callback.
I call cppcheck with the following options
--library=motif.cfg --platform=unix64 --std=c99 --enable=all
The motif.cfg contains an entry for XtAddCallback:
<function name="XtAddCallback">
<leak-ignore>
<returnvalue type="void">
<arg nr="1">
<not-uninit>
</not-uninit></arg>
<arg nr="2">
<not-uninit>
</not-uninit></arg>
<arg nr="4">
</arg></returnvalue></leak-ignore></function>
So I am not sure if false positive is caused by bad definition in motif.cfg or by cppcheck itself.
The code from the example is part of the open source Extended Motif FileSelectionBos
https://sourceforge.net/projects/motifextfsb/
Shouldn't the
data
pointer still be saved somewhere so it can be free'd later?It is saved in the callback, and SelectViewItemDestroy frees it.