From b32ac57ee5e0519283efa40f6196ba1fce2e753d Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Wed, 25 Sep 2013 15:37:10 +0100 Subject: [PATCH] Avoid use of uninitialized data in virnetmessagetest If an error occurs in virnetmessagetest it was possible it would free uninitialized data. Signed-off-by: Daniel P. Berrange --- tests/virnetmessagetest.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/virnetmessagetest.c b/tests/virnetmessagetest.c index 3c9bead5d3..eabc609501 100644 --- a/tests/virnetmessagetest.c +++ b/tests/virnetmessagetest.c @@ -327,6 +327,8 @@ static int testMessagePayloadDecode(const void *args ATTRIBUTE_UNUSED) }; int ret = -1; + memset(&err, 0, sizeof(err)); + if (!msg) return -1; @@ -334,7 +336,6 @@ static int testMessagePayloadDecode(const void *args ATTRIBUTE_UNUSED) if (VIR_ALLOC_N(msg->buffer, msg->bufferLength) < 0) goto cleanup; memcpy(msg->buffer, input_buffer, msg->bufferLength); - memset(&err, 0, sizeof(err)); if (virNetMessageDecodeLength(msg) < 0) { VIR_DEBUG("Failed to decode message header"); -- GitLab