Menu

false memory leak report on mmap call

Tzafrir
2019-09-23
2019-09-23
  • Tzafrir

    Tzafrir - 2019-09-23

    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;
    }

     
  • versat

    versat - 2019-09-23

    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.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.