GNOME Bugzilla – Bug 684140
gnome-xkb-info: Fix memory leaks
Last modified: 2012-09-16 22:37:55 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.
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.
Rui, can you have a look ?
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.
*** Bug 677295 has been marked as a duplicate of this bug. ***
GHashTable is a terrible interface for not being leaky. That looks good.
Attachment 224464 [details] pushed as c5ec270 - gnome-xkb-info: Fix memory leak