I'd like to write a cfg file entry for the posix scandir() function that enables cppcheck to detect memory leaks associated with that function.
int scandir(const char *dirp, struct dirent ***namelist,
int (*filter)(const struct dirent *),
int (*compar)(const struct dirent **, const struct dirent **));
After calling calling scandir() it is necessary to call free(namelist). It wasn't obvious to me from the cppcheck manual, Library Editor or other cfg files what settings I need to make for arg2 so cppcheck is aware of the need for the free() call.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I could be wrong.. but as far as I remember you can't configure this. And after a quick look.. it does not seem we have a ticket that is directly applicable. There are a few tickets with keyword "library" about memory leaks, so I guess they are a bit related. Feel free to open a new ticket.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'd like to write a cfg file entry for the posix
scandir()
function that enables cppcheck to detect memory leaks associated with that function.int scandir(const char *dirp, struct dirent ***namelist, int (*filter)(const struct dirent *), int (*compar)(const struct dirent **, const struct dirent **));
After calling calling
scandir()
it is necessary to callfree(namelist)
. It wasn't obvious to me from the cppcheck manual, Library Editor or other cfg files what settings I need to make forarg2
so cppcheck is aware of the need for thefree()
call.I could be wrong.. but as far as I remember you can't configure this. And after a quick look.. it does not seem we have a ticket that is directly applicable. There are a few tickets with keyword "library" about memory leaks, so I guess they are a bit related. Feel free to open a new ticket.
This ticket is releated:
https://trac.cppcheck.net/ticket/6994 ("Please enable memory leak check to function ("output") arguments also").