mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] hush: Fix a memory leak in run_command()
@ 2022-07-14 16:41 Uwe Kleine-König
  2023-04-12 11:29 ` Uwe Kleine-König
  0 siblings, 1 reply; 2+ messages in thread
From: Uwe Kleine-König @ 2022-07-14 16:41 UTC (permalink / raw)
  To: barebox

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@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




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-04-12 11:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-14 16:41 [PATCH] hush: Fix a memory leak in run_command() Uwe Kleine-König
2023-04-12 11:29 ` Uwe Kleine-König

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox