summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-01-15 11:55:46 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-01-15 12:39:15 -0500
commite50412ef194475b2c36bd91803ddede657627b2c (patch)
tree94ac5146882fcda78e07aeee9c168747ba1d0ac8 /src
parent6fefc0eded00974e5b2862bd5efc7ef975c6a318 (diff)
journalctl: fix memleak
This is harmless, it would only happen if --verify-key is used multiple times. But let's fix it for correctness. CID ##1368415.
Diffstat (limited to 'src')
-rw-r--r--src/journal/journalctl.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index 73204b3753..2a5f2b37e8 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -683,11 +683,12 @@ static int parse_argv(int argc, char *argv[]) {
case ARG_VERIFY_KEY:
arg_action = ACTION_VERIFY;
- arg_verify_key = strdup(optarg);
- if (!arg_verify_key)
- return -ENOMEM;
- arg_merge = false;
+ r = free_and_strdup(&arg_verify_key, optarg);
+ if (r < 0)
+ return r;
string_erase(optarg);
+
+ arg_merge = false;
break;
case ARG_INTERVAL:
@@ -888,7 +889,7 @@ static int parse_argv(int argc, char *argv[]) {
* to users, and automatically turn --unit= into --user-unit= if combined with --user. */
r = strv_extend_strv(&arg_user_units, arg_system_units, true);
if (r < 0)
- return -ENOMEM;
+ return r;
arg_system_units = strv_free(arg_system_units);
}