Menu

Why doesn't this report a memory leak

Erez
2022-10-13
2022-10-13
  • Erez

    Erez - 2022-10-13

    Hi, I'm trying to learn Cppcheck. I made this program in an Empty Project in Visual Studio:

    #include <stdlib.h>
    #include <stdio.h>
    #include <rpc.h>
    
    int main()
    {
        SID_IDENTIFIER_AUTHORITY sia = { 0 };
        PSID sid = NULL;
        AllocateAndInitializeSid(&sia, 1, 0, 0, 0, 0, 0, 0, 0, 0, &sid);
        return EXIT_SUCCESS;
    }
    

    Installed Cppcheck 2.9 and created a new project, specified the .sln and checked the windows library.
    I expect it to report an error about a memory leak since AllocateAndInitializeSid is defined in windows.cfg as allocating memory that needs to be freed by FreeSid. However, it does not report any problem at all. Why is that?

     
  • CHR

    CHR - 2022-10-13
     

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.