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

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: 3f36ce9ab63ed92e754a78be3ebbd9fa9b481b34
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 517011796c..511ca6ef95 100644
--- a/src/common/slurm_protocol_pack.c
+++ b/src/common/slurm_protocol_pack.c
@@ -14058,6 +14058,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