aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosé María Alonso <nimiux.gentoo.org>2012-02-04 18:12:18 +0100
committerJosé María Alonso <nimiux.gentoo.org>2012-02-04 18:12:18 +0100
commit7193aa1fa1a5dbf2f0c714ff0e88f04bea5e962f (patch)
treeaedd04de0e741ee73e2ad45b32068e9d6badb111 /index.c
parentUse of bzip2 for dist files (diff)
downloadconf-update-7193aa1fa1a5dbf2f0c714ff0e88f04bea5e962f.tar.gz
conf-update-7193aa1fa1a5dbf2f0c714ff0e88f04bea5e962f.tar.bz2
conf-update-7193aa1fa1a5dbf2f0c714ff0e88f04bea5e962f.zip
Fixed some memory leaks. Thanks to Vincent Huisman.
Diffstat (limited to 'index.c')
-rw-r--r--index.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/index.c b/index.c
index 96bb227..5048da4 100644
--- a/index.c
+++ b/index.c
@@ -45,14 +45,16 @@ MENU *create_menu(char **protected) {
void remove_menu(MENU *mymenu) {
ITEM **item_list = menu_items(mymenu);
- int i;
+ int i, cnt;
unpost_menu(mymenu);
- for (i=0;i<item_count(mymenu);i++) {
+ // Docs say: first free menu, then free items and only then the item list, not in any other order
+ cnt = item_count(mymenu);
+ free_menu(mymenu);
+ for (i=0;i<cnt;i++) {
free((char *)item_name(item_list[i]));
free_item(item_list[i]);
}
free(item_list);
- free_menu(mymenu);
}