analyzing the following file with --std-posix report false error on the return statement. Seems like cppcheck fails detecting that mmap failed and no memory was allocated in this case
uint8_t mmap_mem_leak_error() { void data = mmap(NULL, 10, PROT_READ, MAP_PRIVATE, 1, 0); if (data != MAP_FAILED) return data; return NULL; }
Thanks for reporting that issue. I have reopened and updated a ticket describing it: https://trac.cppcheck.net/ticket/8327
Log in to post a comment.
analyzing the following file with --std-posix report false error on the
return statement.
Seems like cppcheck fails detecting that mmap failed and no memory was
allocated in this case
include <sys mman.h=""></sys>
uint8_t mmap_mem_leak_error()
{
void data = mmap(NULL, 10, PROT_READ, MAP_PRIVATE, 1, 0);
if (data != MAP_FAILED)
return data;
return NULL;
}
Thanks for reporting that issue.
I have reopened and updated a ticket describing it:
https://trac.cppcheck.net/ticket/8327