From: Alejandro Colomar Date: Wed, 16 Jul 2025 15:41:33 +0000 (+0200) Subject: lib/utmp.c: get_current_utmp(): Don't exit(3) from library code X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4b3f657aa3e16b34b7a04a39999745dbd4c98863;p=thirdparty%2Fshadow.git lib/utmp.c: get_current_utmp(): Don't exit(3) from library code This function already returned NULL on some errors. It didn't make any sense to exit(3) on allocation failure. Instead, just return NULL. Reviewed-by: "Evgeny Grin (Karlson2k)" Signed-off-by: Alejandro Colomar --- diff --git a/lib/utmp.c b/lib/utmp.c index 3c2a51aab..00fac8ffa 100644 --- a/lib/utmp.c +++ b/lib/utmp.c @@ -185,8 +185,9 @@ get_current_utmp(pid_t main_pid) if (NULL != ut) { struct utmpx *ut_copy; - ut_copy = xmalloc_T(1, struct utmpx); - memcpy(ut_copy, ut, sizeof(*ut)); + ut_copy = malloc_T(1, struct utmpx); + if (ut_copy != NULL) + memcpy(ut_copy, ut, sizeof(*ut)); ut = ut_copy; }