From: Andrew Au Date: Tue, 3 Sep 2019 20:46:21 +0000 (-0700) Subject: Fix memory leak (#457) X-Git-Tag: submit/tizen/20191015.063341~12^2^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dfd3acc774bb4406c64259a0b70bac1328ec68e4;p=platform%2Fcore%2Fdotnet%2Fdiagnostics.git Fix memory leak (#457) --- diff --git a/src/SOS/Strike/strike.cpp b/src/SOS/Strike/strike.cpp index f14b8c4ef..439fd5e92 100644 --- a/src/SOS/Strike/strike.cpp +++ b/src/SOS/Strike/strike.cpp @@ -9313,7 +9313,7 @@ DECLARE_API(u) return Status; } - CLRDATA_IL_ADDRESS_MAP* map = nullptr; + ArrayHolder map(nullptr); ULONG32 mapCount = 0; if ((Status = pMethodInst->GetILAddressMap(mapCount, &mapCount, map)) != S_OK) @@ -9321,7 +9321,12 @@ DECLARE_API(u) return Status; } - map = new CLRDATA_IL_ADDRESS_MAP[mapCount]; + map = new NOTHROW CLRDATA_IL_ADDRESS_MAP[mapCount]; + if (map == NULL) + { + ReportOOM(); + return E_OUTOFMEMORY; + } if ((Status = pMethodInst->GetILAddressMap(mapCount, &mapCount, map)) != S_OK) { @@ -9334,8 +9339,6 @@ DECLARE_API(u) // Decoded IL can be obtained through refactoring DumpIL code. ExtOut("%04x %p %p\n", map[i].ilOffset, map[i].startAddress, map[i].endAddress); } - - delete[] map; } if (codeHeaderData.ColdRegionStart != NULL)