bf0817f
From 2616c6be1c244424617997151c67bcab2dacbcfe Mon Sep 17 00:00:00 2001
bf0817f
From: rpm-build <rpm-build>
bf0817f
Date: Thu, 31 Aug 2023 14:34:05 +0200
bf0817f
Subject: [PATCH] coreutils-9.4-systemd-coredump.patch
bf0817f
bf0817f
Cherry picked from gnulib upstream commits:
bf0817f
* 1e6a26f9312bb47e070f94b17b14dc1a6ffbb74f ("readutmp: fix core dump if --enable-systemd")
bf0817f
* 3af1d7b0ce3a8e3ae565e7cea10cee6fd7cb8109 ("readutmp: Fix memory leak introduced by last commit.")
bf0817f
---
bf0817f
 lib/readutmp.c | 2 +-
bf0817f
 1 file changed, 1 insertion(+), 1 deletion(-)
bf0817f
bf0817f
diff --git a/lib/readutmp.c b/lib/readutmp.c
bf0817f
index 0173b7e..ec09feb 100644
bf0817f
--- a/lib/readutmp.c
bf0817f
+++ b/lib/readutmp.c
bf0817f
@@ -795,7 +795,7 @@ read_utmp_from_systemd (idx_t *n_entries, STRUCT_UTMP **utmp_buf, int options)
bf0817f
     {
bf0817f
       char **sessions;
bf0817f
       int num_sessions = sd_get_sessions (&sessions);
bf0817f
-      if (num_sessions >= 0)
bf0817f
+      if (num_sessions >= 0 && sessions != NULL)
bf0817f
         {
bf0817f
           char **session_ptr;
bf0817f
           for (session_ptr = sessions; *session_ptr != NULL; session_ptr++)
bf0817f
-- 
bf0817f
2.41.0
bf0817f