even though the call to whatever fptr points to might free or take ownership of buf.
However, this similar function correctly reports no errors.
void f() {
void *buf = malloc(1);
g(buf);
}
It is because in lib/checkleakautovar.cpp the "do we call a function" code only matches functions that are called with the standard "%name% (" syntax. I have a branch which modifies this check to handle function calls through function pointers, lambdas, and through functions that return function pointers like get_function()(buf). If it is helpful, I can make a PR once there is an issue.
Best,
Aaron
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello
When analyzing this function with
./cppcheck test.cI get
even though the call to whatever fptr points to might free or take ownership of buf.
However, this similar function correctly reports no errors.
It is because in lib/checkleakautovar.cpp the "do we call a function" code only matches functions that are called with the standard
"%name% ("syntax. I have a branch which modifies this check to handle function calls through function pointers, lambdas, and through functions that return function pointers likeget_function()(buf). If it is helpful, I can make a PR once there is an issue.Best,
Aaron
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/14990
Thanks, pr is here: https://github.com/cppcheck-opensource/cppcheck/pull/8813