diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2021-03-22 07:55:25 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2021-03-22 10:18:42 +0100 |
commit | ca2cc1e48bbcbc9b3d20d20d859e6d2dc351ec36 (patch) | |
tree | 1cc55ff1377cc4d006831caf0281b0e1ab0485a5 /commands | |
parent | f8bea406c27220e053e6adecba7729f93de9768d (diff) | |
download | barebox-ca2cc1e48bbcbc9b3d20d20d859e6d2dc351ec36.tar.gz barebox-ca2cc1e48bbcbc9b3d20d20d859e6d2dc351ec36.tar.xz |
commands: readline: fix memory leak on wrong usage
Later error-handling frees buf, but the first early exit doesn't.
Move buf beyond it to fix the memory leak.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands')
-rw-r--r-- | commands/readline.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/commands/readline.c b/commands/readline.c index 403ac8563a..7933a58c08 100644 --- a/commands/readline.c +++ b/commands/readline.c @@ -10,11 +10,13 @@ static int do_readline(int argc, char *argv[]) { - char *buf = xzalloc(CONFIG_CBSIZE); + char *buf; if (argc < 3) return COMMAND_ERROR_USAGE; + buf = xzalloc(CONFIG_CBSIZE); + command_slice_release(); if (readline(argv[1], buf, CONFIG_CBSIZE) < 0) { |