From dfaefc2560012708278cfd180cf59c468edb7487 Mon Sep 17 00:00:00 2001 From: rephorm Date: Wed, 20 Dec 2006 19:50:37 +0000 Subject: [PATCH] don't leak when input is invalid ( w/o an e.g.) add a fixme SVN revision: 27527 --- .../src/lib/ecore_desktop/ecore_desktop_menu.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_menu.c b/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_menu.c index 9dc2c03d00..8fa7210a35 100644 --- a/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_menu.c +++ b/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_menu.c @@ -266,6 +266,7 @@ printf("MENU FILE %d - %s\n", level, file); /* Setup the merge stack. */ if (merge_stack->size <= level) { + /* XXX storing a pointer to a static string probably isn't a good idea. this is most likely the cause of the valgrind error mentioned below. (once this function has exited that memory will no longer be valid) */ while (merge_stack->size < level) ecore_desktop_tree_add(merge_stack, ""); ecore_desktop_tree_add(merge_stack, file); @@ -294,6 +295,9 @@ printf("MENU FILE %d - %s\n", level, file); * which is the strcmp just above. But it doesn't complain about the first two if's, * or the printf, which I inserted to try and track this down. * No idea what it actually is complaining about, so I'll comment it for future study. + * + * This is probably caused by the fact that a static string was passed into the + * tree. See the comment above where this occurs. */ fprintf(stderr, "\n### Oops, infinite menu merging loop detected at %s\n", @@ -1029,11 +1033,12 @@ _ecore_desktop_menu_unxml_moves(Ecore_Desktop_Tree * menu, sprintf(temp, " <%s>", old, new); ecore_desktop_tree_extend(menu, temp); - free(old); - old = NULL; - free(new); - new = NULL; } + + if (old) free(old); + old = NULL; + if (new) free(new); + new = NULL; } }