diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-07-16 17:16:42 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-07-17 12:07:19 +0200 |
commit | bfbf5f7408b3ded4f50012184d408f4395a577ca (patch) | |
tree | 5d77e0683c47062218e17acaf45323fd2518589c /src/firstboot | |
parent | 476da0fe00b863123461396d6acb403c92a806a5 (diff) | |
download | systemd-bfbf5f7408b3ded4f50012184d408f4395a577ca.tar.gz |
firstboot: use free_and_strdup, free_and_replace
Diffstat (limited to 'src/firstboot')
-rw-r--r-- | src/firstboot/firstboot.c | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/src/firstboot/firstboot.c b/src/firstboot/firstboot.c index 74b83f348b..dca3a25e34 100644 --- a/src/firstboot/firstboot.c +++ b/src/firstboot/firstboot.c @@ -186,21 +186,15 @@ static int prompt_loop(const char *text, char **l, bool (*is_valid)(const char * r = safe_atou(p, &u); if (r >= 0) { - char *c; - if (u <= 0 || u > strv_length(l)) { log_error("Specified entry number out of range."); continue; } log_info("Selected '%s'.", l[u-1]); - - c = strdup(l[u-1]); - if (!c) + if (free_and_strdup(ret, l[u-1]) < 0) return log_oom(); - free(*ret); - *ret = c; return 0; } @@ -209,10 +203,7 @@ static int prompt_loop(const char *text, char **l, bool (*is_valid)(const char * continue; } - free(*ret); - *ret = p; - p = 0; - return 0; + return free_and_replace(*ret, p); } } |