Re: [v2] trap: fix memory leak in exitshell()

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

 



On Tue, 6 Mar 2018, Herbert Xu wrote:

On Thu, Dec 01, 2016 at 10:17:07PM +0100, Andreas Bofjall wrote:
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>

This is not needed because we're about to exit so all memory will
be going back to the OS.

You're correct, but the problem is the pointer is overwritten before returning. That means before dash has exited, it is properly detected as a leak by e.g. valgrind.

I was debugging a memory leak and it was very convenient to be able to quickly wrap some test stuff in dash, which is when I stumbled on this because the tests started failing on this memory leak in dash instead of the leaks I was trying to fix.

Perhaps it's an exoteric use case, but it would be nice if it was fixed.

/Andreas
--
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