[PATCH 7/9] menu: fix memory corruption
Sascha Hauer
s.hauer at pengutronix.de
Mon Aug 23 02:24:11 EDT 2010
menu_free and menu_entry_free are called on not fully initialized
entries, so we have to check for validity before freeing the
members.
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
common/menu.c | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/common/menu.c b/common/menu.c
index 6e6637a..294e372 100644
--- a/common/menu.c
+++ b/common/menu.c
@@ -46,8 +46,10 @@ void menu_free(struct menu *m)
if (!m)
return;
- free(m->name);
- free(m->display);
+ if (m->name)
+ free(m->name);
+ if (m->display)
+ free(m->display);
list_for_each_entry_safe(me, tmp, &m->entries, list)
menu_entry_free(me);
@@ -143,7 +145,9 @@ void menu_entry_free(struct menu_entry *me)
if (!me)
return;
- free(me->display);
+ if (me->display)
+ free(me->display);
+
free(me);
}
--
1.7.1
More information about the barebox
mailing list