From ffd008363c9ece751a243ce0cfd4c4a19b51ab8b Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Mon, 8 Dec 2014 11:09:36 +0100 Subject: [PATCH] core: don't leak memory in specifier_user_name() in case of error --- src/core/unit-printf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/unit-printf.c b/src/core/unit-printf.c index 62599d0..bee3449 100644 --- a/src/core/unit-printf.c +++ b/src/core/unit-printf.c @@ -234,8 +234,10 @@ static int specifier_user_name(char specifier, void *data, void *userdata, char r = asprintf(&printed, UID_FMT, uid); } - if (r < 0 || !printed) + if (r < 0 || !printed) { + free(printed); return -ENOMEM; + } *ret = printed; return 0; -- 2.1.3