[PATCH 2/3] hush: fix nasty memory leak in hush

Sascha Hauer s.hauer at pengutronix.de
Fri Oct 8 08:24:33 EDT 2010


Fix memory leak in globbing part of hush. a simple '['
on the command line was enough to trigger it.
We must call globfree() before setting the glob structure
to zero.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 common/hush.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/common/hush.c b/common/hush.c
index f22eca6..1b5cd99 100644
--- a/common/hush.c
+++ b/common/hush.c
@@ -790,6 +790,7 @@ static int globhack(const char *src, int flags, glob_t *pglob)
 	}
 	dest = xmalloc(cnt);
 	if (!(flags & GLOB_APPEND)) {
+		globfree(pglob);
 		pglob->gl_pathv = NULL;
 		pglob->gl_pathc = 0;
 		pglob->gl_offs = 0;
-- 
1.7.2.3




More information about the barebox mailing list