[PATCH] hush: Fix a memory leak in run_command()

Uwe Kleine-König u.kleine-koenig at pengutronix.de
Thu Jul 14 09:41:18 PDT 2022


parse_string_outer() calls initialize_context(), too. As the latter
allocates memory make sure to only call it once.

This fixes

	automount -d /mnt/foo true
	ls -l /mnt/foo

dying with a failure to allocate memory. Now it results in an endless loop,
which admittedly is only a little bit better :-)

Signed-off-by: Uwe Kleine-König <u.kleine-koenig at pengutronix.de>
---
 common/hush.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/common/hush.c b/common/hush.c
index 6a089fabf11d..117b273ea4e2 100644
--- a/common/hush.c
+++ b/common/hush.c
@@ -1887,8 +1887,6 @@ int run_command(const char *cmd)
 	struct p_context ctx = {};
 	int ret;
 
-	initialize_context(&ctx);
-
 	ret = parse_string_outer(&ctx, cmd, FLAG_PARSE_SEMICOLON);
 	release_context(&ctx);
 

base-commit: 298727bc7931fe878fd72a1fa6f35c18bd7c593c
-- 
2.36.1




More information about the barebox mailing list