File U_02-Protect-against-double-xfree.patch of Package slurm.32299

From: Tim Wickberg <tim@schedmd.com>
Date: Tue Nov 28 17:05:18 2023 -0700
Subject: [PATCH 2/28]Protect against double-xfree().
Patch-mainline: Upstream
Git-repo: https://github.com/SchedMD/slurm
Git-commit: 97fa72be6c700794e7909228cc5bc6abfaee93ce
References: bsc#1218046, bsc#1218050, bsc#1218051, bsc#1218053
Signed-off-by: Egbert Eich <eich@suse.de>

---
 src/common/slurm_protocol_pack.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/common/slurm_protocol_pack.c b/src/common/slurm_protocol_pack.c
index eabdeb8742..e6c1a2fe62 100644
--- a/src/common/slurm_protocol_pack.c
+++ b/src/common/slurm_protocol_pack.c
@@ -13423,6 +13423,15 @@ unpack_msg(slurm_msg_t * msg, Buf buffer)
 	if (rc) {
 		error("Malformed RPC of type %s(%u) received",
 		      rpc_num2string(msg->msg_type), msg->msg_type);
+
+		/*
+		 * The unpack functions should not leave this set on error,
+		 * doing so would likely result in a double xfree() if we
+		 * did not proactively clear it. (Which, instead, may cause
+		 * a memory leak. But that's preferrable.)
+		 */
+		xassert(msg->data);
+		msg->data = NULL;
 	}
 	return rc;
 }
openSUSE Build Service is sponsored by