From: Alejandro Colomar Date: Wed, 16 Jul 2025 15:44:26 +0000 (+0200) Subject: lib/utmp.c: get_current_utmp(): Use memdup_T() instead of its pattern X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eb28858358199afeabbd5532943565958faf78a8;p=thirdparty%2Fshadow.git lib/utmp.c: get_current_utmp(): Use memdup_T() instead of its pattern Reviewed-by: "Evgeny Grin (Karlson2k)" Signed-off-by: Alejandro Colomar --- diff --git a/lib/utmp.c b/lib/utmp.c index 678f9ac4f..f5fd2a57e 100644 --- a/lib/utmp.c +++ b/lib/utmp.c @@ -36,6 +36,7 @@ #include "string/strcmp/strneq.h" #include "string/strcmp/strprefix.h" #include "string/strcpy/strncpy.h" +#include "string/strdup/memdup.h" #include "string/strdup/strdup.h" #include "string/strdup/strndup.h" @@ -182,14 +183,8 @@ get_current_utmp(pid_t main_pid) if (NULL == ut) ut = ut_by_pid ?: ut_by_line; - if (NULL != ut) { - struct utmpx *ut_copy; - - ut_copy = malloc_T(1, struct utmpx); - if (ut_copy != NULL) - *ut_copy = *ut; - ut = ut_copy; - } + if (NULL != ut) + ut = memdup_T(ut, struct utmpx); free(ut_by_line); free(ut_by_pid);