From c163f973e6a96a2c37d70cc1992f2bb027f9ab81 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sat, 14 Jul 2012 11:24:22 -0400 Subject: [PATCH] Fix resource leak in error cases. CID 611238. --- src/apps/debugger/value/value_nodes/BMessageValueNode.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/apps/debugger/value/value_nodes/BMessageValueNode.cpp b/src/apps/debugger/value/value_nodes/BMessageValueNode.cpp index 8316d6e8dc..b805a35332 100644 --- a/src/apps/debugger/value/value_nodes/BMessageValueNode.cpp +++ b/src/apps/debugger/value/value_nodes/BMessageValueNode.cpp @@ -281,6 +281,9 @@ BMessageValueNode::ResolvedLocationAndValue(ValueLoader* valueLoader, uint8* messageBuffer = new(std::nothrow) uint8[totalSize]; if (messageBuffer == NULL) return B_NO_MEMORY; + + ArrayDeleter deleter(messageBuffer); + memset(messageBuffer, 0, totalSize); memcpy(messageBuffer, fHeader, sizeof(BMessage::message_header)); uint8* tempBuffer = messageBuffer + sizeof(BMessage::message_header); @@ -313,7 +316,6 @@ BMessageValueNode::ResolvedLocationAndValue(ValueLoader* valueLoader, } error = fMessage.Unflatten((const char*)messageBuffer); - delete[] messageBuffer; if (error != B_OK) return error;