Public bug reported:

When the IBUS initialization fails a string is leaked:

        ibus_addr_file = SDL_strdup(addr_file); // Allocate memory
        
        addr = IBus_ReadAddressFromFile(addr_file);
        if (!addr) {
            SDL_free(addr_file);
            return SDL_FALSE; // This will make the SDL_IBus_Quit not called 
hence ibus_addr_file is not freed
        }

Possible solution: Move the ibus_addr_file assignment to the bottom and
make it conditional on result (only copy if true)

Found via LSAN after a simple SDL_InitVideo(); SDL_Quit(); from inside
dynamically loaded shared library.

** Affects: libsdl2 (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1839447

Title:
  Memory leak in SDL_IBus_Init

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/libsdl2/+bug/1839447/+subscriptions

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to