diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2022-09-05 11:55:38 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2022-09-12 12:04:49 +0200 |
commit | 3e705244fc52dd77faa3027530c60d9355c85796 (patch) | |
tree | 0913f413b6e35476118ffd6301fa9697309384e9 /commands | |
parent | 679b989d095a617326bf8d84545a865f3f139861 (diff) | |
download | barebox-3e705244fc52dd77faa3027530c60d9355c85796.tar.gz |
commands: tutorial: fix memory leak
We don't need to duplicate argv[i], because it persists for the lifetime
of print_tutorial_step. We can thus drop the strdup and while at it,
just drop the redundant step variable altogether.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20220905095557.596891-14-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands')
-rw-r--r-- | commands/tutorial.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/commands/tutorial.c b/commands/tutorial.c index 4441777643..afe5b66f0b 100644 --- a/commands/tutorial.c +++ b/commands/tutorial.c @@ -84,7 +84,6 @@ out: static int do_tutorial_next(int argc, char *argv[]) { int opt, i; - char *step = NULL; char *oldcwd; ssize_t ret = 0; bool is_prev = *argv[0] == 'p'; @@ -121,14 +120,12 @@ static int do_tutorial_next(int argc, char *argv[]) next_step = next_step > 0 ? next_step - 1 : 0; if (optind == argc) { - step = steps.gl_pathv[next_step]; - ret = print_tutorial_step(step); + ret = print_tutorial_step(steps.gl_pathv[next_step]); if (ret == 0 && !is_prev) next_step = (next_step + 1) % steps.gl_pathc; } else { for (i = optind; i < argc; i++) { - step = strdup(argv[i]); - ret = print_tutorial_step(step); + ret = print_tutorial_step(argv[i]); if (ret) break; } |