Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit c8f12d0

Browse files
author
Evgeny Pavlov
committed
Change 'Extract' -> 'GetValue' to prevent memory leaks
1 parent 2f99c8c commit c8f12d0

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/vm/gdbjit.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ void NotifyGdb::MethodCompiled(MethodDesc* MethodDescPtr)
346346

347347
/* Patch section offsets & sizes */
348348
long offset = sizeof(Elf_Ehdr);
349-
Elf_Shdr* pShdr = reinterpret_cast<Elf_Shdr*>(sectHeaders.MemPtr.Extract());
349+
Elf_Shdr* pShdr = reinterpret_cast<Elf_Shdr*>(sectHeaders.MemPtr.GetValue());
350350
++pShdr; // .text
351351
pShdr->sh_addr = pCode;
352352
pShdr->sh_size = codeSize;
@@ -384,7 +384,7 @@ void NotifyGdb::MethodCompiled(MethodDesc* MethodDescPtr)
384384
{
385385
return;
386386
}
387-
Elf_Ehdr* header = reinterpret_cast<Elf_Ehdr*>(elfHeader.MemPtr.Extract());
387+
Elf_Ehdr* header = reinterpret_cast<Elf_Ehdr*>(elfHeader.MemPtr.GetValue());
388388
#ifdef _TARGET_ARM_
389389
header->e_flags = EF_ARM_EABI_VER5;
390390
#ifdef ARM_SOFTFP
@@ -516,7 +516,7 @@ bool NotifyGdb::BuildLineTable(MemBuf& buf, PCODE startAddr, SymbolsInfo* lines,
516516
}
517517

518518
/* Fill the line info header */
519-
DwarfLineNumHeader* header = reinterpret_cast<DwarfLineNumHeader*>(buf.MemPtr.Extract());
519+
DwarfLineNumHeader* header = reinterpret_cast<DwarfLineNumHeader*>(buf.MemPtr.GetValue());
520520
memcpy(buf.MemPtr, &LineNumHeader, sizeof(DwarfLineNumHeader));
521521
header->m_length = buf.MemSize - sizeof(uint32_t);
522522
header->m_hdr_length = sizeof(DwarfLineNumHeader) + 1 + fileTable.MemSize - 2 * sizeof(uint32_t) - sizeof(uint16_t);
@@ -535,7 +535,7 @@ bool NotifyGdb::BuildFileTable(MemBuf& buf, SymbolsInfo* lines, unsigned nlines)
535535
const char** files = nullptr;
536536
unsigned nfiles = 0;
537537

538-
/* Extract file names and replace them with indices in file table */
538+
/* GetValue file names and replace them with indices in file table */
539539
files = new (nothrow) const char*[nlines];
540540
if (files == nullptr)
541541
return false;
@@ -753,7 +753,7 @@ bool NotifyGdb::BuildDebugInfo(MemBuf& buf)
753753
return false;
754754

755755
/* Compile uint header */
756-
DwarfCompUnit* cu = reinterpret_cast<DwarfCompUnit*>(buf.MemPtr.Extract());
756+
DwarfCompUnit* cu = reinterpret_cast<DwarfCompUnit*>(buf.MemPtr.GetValue());
757757
cu->m_length = buf.MemSize - sizeof(uint32_t);
758758
cu->m_version = 4;
759759
cu->m_abbrev_offset = 0;
@@ -783,7 +783,7 @@ bool NotifyGdb::BuildDebugPub(MemBuf& buf, const char* name, uint32_t size, uint
783783
if (buf.MemPtr == nullptr)
784784
return false;
785785

786-
DwarfPubHeader* header = reinterpret_cast<DwarfPubHeader*>(buf.MemPtr.Extract());
786+
DwarfPubHeader* header = reinterpret_cast<DwarfPubHeader*>(buf.MemPtr.GetValue());
787787
header->m_length = length - sizeof(uint32_t);
788788
header->m_version = 2;
789789
header->m_debug_info_off = 0;

0 commit comments

Comments
 (0)