]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/utmp.c: get_current_utmp(): Don't exit(3) from library code
authorAlejandro Colomar <alx@kernel.org>
Wed, 16 Jul 2025 15:41:33 +0000 (17:41 +0200)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Tue, 17 Feb 2026 09:45:39 +0000 (10:45 +0100)
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)" <k2k@drgrin.dev>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/utmp.c

index 3c2a51aab528c8432b0fc6b746c9295cd2262326..00fac8ffa9b854d648e801dae4d075c0042d759a 100644 (file)
@@ -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;
        }