Bug 169549 - Memory leak in create_menu() (menu.c)
Summary: Memory leak in create_menu() (menu.c)
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: mc
Version: 4
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jindrich Novy
QA Contact:
URL: http://mail.gnome.org/archives/mc-dev...
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2005-09-29 15:44 UTC by Marcin Garski
Modified: 2013-07-02 23:09 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2005-09-29 17:56:24 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

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.


Note You need to log in before you can comment on or make changes to this bug.