From 0e62a125bdf44b842fcbfef85480852f6d6cdc38 Mon Sep 17 00:00:00 2001 From: Ravitheja Addepally Date: Fri, 26 May 2017 14:26:14 +0000 Subject: [PATCH] Fixing Memory Leak llvm-svn: 303991 --- .../Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp index 5aa2f49..a3e5ce3 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp @@ -1300,13 +1300,13 @@ GDBRemoteCommunicationServerLLGS::Handle_jTraceRead( json_dict->GetValueForKeyAsInteger("threadid", tid); // Allocate the response buffer. - uint8_t *buffer = new (std::nothrow) uint8_t[byte_count]; - if (buffer == nullptr) + std::unique_ptr buffer (new (std::nothrow) uint8_t[byte_count]); + if (!buffer) return SendErrorResponse(0x78); StreamGDBRemote response; Status error; - llvm::MutableArrayRef buf(buffer, byte_count); + llvm::MutableArrayRef buf(buffer.get(), byte_count); if (tracetype == BufferData) error = m_debugged_process_sp->GetData(uid, tid, buf, offset); -- 2.7.4