gnome-terminal leaks memory on startup after call to g_listenv
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
gnome-terminal (Ubuntu) |
Fix Released
|
Low
|
Matt Fischer |
Bug Description
gnome-terminal leaks memory on startup because it calls g_listenv without freeing the resulting list of strings. Per the docs, this list must be freed:
http://
g_listenv(): Returns: a NULL-terminated list of strings which must be freed with g_strfreev(). [array zero-terminated
Here's the valgrind report with the leak:
==13350== 1,877 (728 direct, 1,149 indirect) bytes in 1 blocks are definitely lost in loss record 5,623 of 5,715
==13350== at 0x4C29DB4: calloc (vg_replace_
==13350== by 0x6ABA718: g_malloc0 (gmem.c:189)
==13350== by 0x6AA123F: g_listenv (genviron.c:399)
==13350== by 0x416901: name_lost_cb (terminal.c:328)
==13350== by 0x5EF973D: do_call (gdbusnameownin
==13350== by 0x5EF99AF: request_name_cb (gdbusnameownin
==13350== by 0x5EA0F76: g_simple_
==13350== by 0x5EF1831: g_dbus_
==13350== by 0x5EA0F76: g_simple_
==13350== by 0x5EA1078: complete_in_idle_cb (gsimpleasyncre
==13350== by 0x6AB4A94: g_main_
==13350== by 0x6AB4DC7: g_main_
==13350== by 0x6AB51C1: g_main_loop_run (gmain.c:3484)
==13350== by 0x5464064: gtk_main (gtkmain.c:1160)
==13350== by 0x4135B2: main (terminal.c:601)
tags: | added: patch |
Here's a fix for the issue (attached). I looked upstream and while the issue exists in 3.6.1 it doesn't exist in trunk, so I don't think it needs to go upstream.
Valgrind summary after applying my fix:
==23336== LEAK SUMMARY:
==23336== definitely lost: 0 bytes in 0 blocks
The patch is pretty simple, just free the list that g_listenv() creates.