Fix usage of shared_ptr for array which may cause a undefined behaviour (use unique_p...
authorIlia K <ki.stfu@gmail.com>
Thu, 26 Feb 2015 13:28:58 +0000 (13:28 +0000)
committerIlia K <ki.stfu@gmail.com>
Thu, 26 Feb 2015 13:28:58 +0000 (13:28 +0000)
llvm-svn: 230630

lldb/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp

index 847adf1..650856f 100644 (file)
@@ -948,14 +948,14 @@ CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopException(void)
     const lldb::SBProcess sbProcess = CMICmnLLDBDebugSessionInfo::Instance().GetProcess();
     lldb::SBThread sbThread = sbProcess.GetSelectedThread();
     const size_t nStopDescriptionLen = sbThread.GetStopDescription(nullptr, 0);
-    std::shared_ptr<char> spStopDescription(new char[nStopDescriptionLen]);
-    sbThread.GetStopDescription(spStopDescription.get(), nStopDescriptionLen);
+    std::unique_ptr<char[]> apStopDescription(new char[nStopDescriptionLen]);
+    sbThread.GetStopDescription(apStopDescription.get(), nStopDescriptionLen);
 
     // MI print "*stopped,reason=\"exception-received\",exception=\"%s\",thread-id=\"%d\",stopped-threads=\"all\""
     const CMICmnMIValueConst miValueConst("exception-received");
     const CMICmnMIValueResult miValueResult("reason", miValueConst);
     CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_Stopped, miValueResult);
-    const CMIUtilString strReason(spStopDescription.get());
+    const CMIUtilString strReason(apStopDescription.get());
     const CMICmnMIValueConst miValueConst2(strReason);
     const CMICmnMIValueResult miValueResult2("exception", miValueConst2);
     bool bOk = miOutOfBandRecord.Add(miValueResult2);