We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3004

Summary: [patch] Fix IBus leaking memory (D-Bus address filename)
Product: SDL Reporter: Zack Middleton (zturtleman) <zack>
Component: *don't know*Assignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: sezeroz
Version: HG 2.0Keywords: target-2.0.4
Hardware: x86_64   
OS: Linux   
Attachments: Patch to fix IBus memory leak

Description Zack Middleton (zturtleman) 2015-06-07 16:27:38 UTC
Created attachment 2172 [details]
Patch to fix IBus memory leak

IBus code does not free the D-Bus address filename in SDL_IBus_Init if the file cannot be read or address not found, causing it to leak memory. It leaks each time the video sub system is (re)started.

The issue occurs in the latest SDL HG revision and was introduced in commit https://hg.libsdl.org/SDL/rev/28c55cb65416 .
Comment 1 Ryan C. Gordon 2015-06-07 21:55:14 UTC
This patch is now https://hg.libsdl.org/SDL/rev/a964d651f1dd, thanks!

--ryan.
Comment 2 Ozkan Sezer 2015-06-12 05:55:50 UTC
The patch looks incorrect to me. The strdup'ed string is ibus_addr_file
and not addr_file, so you actually need the following?

-            SDL_free(addr_file);
+            SDL_free(ibus_addr_file);
Comment 3 Ryan C. Gordon 2015-06-12 16:59:15 UTC
(In reply to Ozkan Sezer from comment #2)
> The patch looks incorrect to me. The strdup'ed string is ibus_addr_file
> and not addr_file, so you actually need the following?
> 
> -            SDL_free(addr_file);
> +            SDL_free(ibus_addr_file);

IBus_GetDBusAddressFilename() returns an allocated string to "addr_file" that we need to free in this failure case. "ibus_addr_file" is a global var we free elsewhere.

This code is nasty in any case, and needs to be cleaned up (it's confusing about who is strdup()'ing what and where, etc), but I'll do that after 2.0.4 ships.

--ryan.