From: Alejandro Colomar Date: Mon, 14 Jul 2025 12:08:52 +0000 (+0200) Subject: lib/utmp.c: get_session_host(): Fix memory leak X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cb1749d7f385b621995ff3c4e8909ac27796a550;p=thirdparty%2Fshadow.git lib/utmp.c: get_session_host(): Fix memory leak Fixes: f40bdfa66a3a (2023-08-02; "libmisc: implement `get_session_host()`") Closes: Signed-off-by: Alejandro Colomar --- diff --git a/lib/utmp.c b/lib/utmp.c index 90ac9d18c..4acf95a7f 100644 --- a/lib/utmp.c +++ b/lib/utmp.c @@ -208,7 +208,6 @@ get_session_host(char **out, pid_t main_pid) #if defined(HAVE_STRUCT_UTMPX_UT_HOST) if ((ut != NULL) && (ut->ut_host[0] != '\0')) { *out = XSTRNDUP(ut->ut_host); - free (ut); } else { *out = NULL; ret = -2; @@ -218,6 +217,8 @@ get_session_host(char **out, pid_t main_pid) ret = -2; #endif + free(ut); + return ret; }