Bug 169549

Summary: Memory leak in create_menu() (menu.c)
Product: [Fedora] Fedora Reporter: Marcin Garski <mgarski>
Component: mcAssignee: Jindrich Novy <jnovy>
Status: CLOSED RAWHIDE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 4CC: leonard-rh-bugzilla, pknirsch
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
URL: http://mail.gnome.org/archives/mc-devel/2005-September/msg00126.html
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-09-29 17:56:24 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Marcin Garski 2005-09-29 15:44:48 UTC
mc-4.6.1a-0.12.FC4

Valgrind report:
==7377== 13 bytes in 1 blocks are definitely lost in loss record 18 of 60
==7377==    at 0x1B909222: malloc (vg_replace_malloc.c:130)
==7377==    by 0x1B954ADF: g_malloc (in /usr/lib/libglib-2.0.so.0.600.6)
==7377==    by 0x1B966DAD: g_strdup (in /usr/lib/libglib-2.0.so.0.600.6)
==7377==    by 0x807D2E1: create_menu (menu.c:62)
==7377==    by 0x807ABE9: init_menu (main.c:939)
==7377==    by 0x807B253: ??? (main.c:1391)
==7377==    by 0x807C432: main (main.c:1762)

Leak is caused by UTF-8 patch.

As I see in create_menu() there is line (62) :
menu->name = g_strdup (name);

and then in line (145) you do:

menu->name = g_strdup (name);

But first name isn't free anywhere. So memory allocated by first g_strdup() is lost.

Also patch add IMHO redundant line:
+    menu_scan_hotkey (menu);

Probably fix for this would be to remove:
menu->name = g_strdup (name);
menu_scan_hotkey(menu);
lines above "menu->start_x = 0;".

Comment 1 Jindrich Novy 2005-09-29 17:56:24 UTC
Ok, fixed. Thanks.