gnome-terminal leaks memory on startup after call to g_listenv

Bug #1088352 reported by Matt Fischer
8
This bug affects 1 person
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://developer.gnome.org/glib/2.32/glib-Miscellaneous-Utility-Functions.html#g-listenv

g_listenv(): Returns: a NULL-terminated list of strings which must be freed with g_strfreev(). [array zero-terminated=1][transfer full]

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_malloc.c:566)
==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 (gdbusnameowning.c:215)
==13350== by 0x5EF99AF: request_name_cb (gdbusnameowning.c:334)
==13350== by 0x5EA0F76: g_simple_async_result_complete (gsimpleasyncresult.c:775)
==13350== by 0x5EF1831: g_dbus_connection_call_done (gdbusconnection.c:5339)
==13350== by 0x5EA0F76: g_simple_async_result_complete (gsimpleasyncresult.c:775)
==13350== by 0x5EA1078: complete_in_idle_cb (gsimpleasyncresult.c:787)
==13350== by 0x6AB4A94: g_main_context_dispatch (gmain.c:2715)
==13350== by 0x6AB4DC7: g_main_context_iterate.isra.24 (gmain.c:3290)
==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: patch
Revision history for this message
Matt Fischer (mfisch) wrote :

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.

tags: added: patch
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package gnome-terminal - 3.6.1-0ubuntu2

---------------
gnome-terminal (3.6.1-0ubuntu2) raring; urgency=low

  * Add patch from Matthew Fischer to fix a memleak by freeing an unfreed
    string array. (LP: #1088352)
 -- Iain Lane <email address hidden> Tue, 11 Dec 2012 18:03:38 +0000

Changed in gnome-terminal (Ubuntu):
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.