[PATCH] trap: fix memory leak in exitshell()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



After dash had executed the exit trap handler, the trap was reset but
the pointer was never freed. This leak can be demonstrated by running
dash through valgrind and executing the following shell script:

	foo() {
	    true
	}
	trap foo EXIT

Fix by properly freeing the trap pointer in exitshell().

Signed-off-by: Andreas Bofjall <andreas@xxxxxxxxxx>
---
 src/trap.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/trap.c b/src/trap.c
index edb9938..5418b07 100644
--- a/src/trap.c
+++ b/src/trap.c
@@ -389,6 +389,7 @@ exitshell(void)
 		trap[0] = NULL;
 		evalskip = 0;
 		evalstring(p, 0);
+		ckfree(p);
 	}
 out:
 	/*
-- 
2.10.2

--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux