After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 684140 - gnome-xkb-info: Fix memory leaks
gnome-xkb-info: Fix memory leaks
Status: RESOLVED FIXED
Product: gnome-desktop
Classification: Core
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: Desktop Maintainers
Desktop Maintainers
: 677295 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2012-09-16 08:47 UTC by Jasper St. Pierre (not reading bugmail)
Modified: 2012-09-16 22:37 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gnome-xkb-info: Fix memory leaks (3.76 KB, patch)
2012-09-16 08:47 UTC, Jasper St. Pierre (not reading bugmail)
none Details | Review
gnome-xkb-info: Fix memory leak (2.27 KB, patch)
2012-09-16 22:10 UTC, Rui Matos
committed Details | Review

Description Jasper St. Pierre (not reading bugmail) 2012-09-16 08:47:39 UTC
This patch has not received extensive testing, and could be horribly wrong.
At best, it "doesn't crash". Somebody with more experience with the code here
should probably review it.

Spotted by darkxst on IRC.
Comment 1 Jasper St. Pierre (not reading bugmail) 2012-09-16 08:47:41 UTC
Created attachment 224439 [details] [review]
gnome-xkb-info: Fix memory leaks

If we replace an old item in the hash table, we have to free the old
item. Do this by duplicating the string, and setting a key free func.
Comment 2 Matthias Clasen 2012-09-16 20:43:13 UTC
Rui, can you have a look ?
Comment 3 Rui Matos 2012-09-16 22:10:44 UTC
Created attachment 224464 [details] [review]
gnome-xkb-info: Fix memory leak

We need to free the current iso639Id string when it doesn't replace a
previous one in the hash table.

--

Thanks for tracking this. I actually knew about this leak but when I
looked at it back then couldn't really spot it and since it's not a
really bad one since the GnomeXkbInfo object usually isn't recreated I
didn't look further.

Your patch addresses the leak but it frees some strings which you
can't free, namely short_desc, since they are "owned" by the Layout
struct. The patch I'm attaching fixes the leak without extra string
copies and the wrong frees.
Comment 4 Rui Matos 2012-09-16 22:13:08 UTC
*** Bug 677295 has been marked as a duplicate of this bug. ***
Comment 5 Jasper St. Pierre (not reading bugmail) 2012-09-16 22:26:28 UTC
GHashTable is a terrible interface for not being leaky. That looks good.
Comment 6 Rui Matos 2012-09-16 22:37:52 UTC
Attachment 224464 [details] pushed as c5ec270 - gnome-xkb-info: Fix memory leak