[llvm] r313146 - [llvm-objdump] Fix memory leaks in macho dump
Francis Ricci via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 13 06:57:45 PDT 2017
Author: fjricci
Date: Wed Sep 13 06:57:45 2017
New Revision: 313146
URL: http://llvm.org/viewvc/llvm-project?rev=313146&view=rev
Log:
[llvm-objdump] Fix memory leaks in macho dump
Summary: Detected by LeakSanitizer for Darwin
Reviewers: enderby, rafael
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D37750
Modified:
llvm/trunk/tools/llvm-objdump/MachODump.cpp
Modified: llvm/trunk/tools/llvm-objdump/MachODump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/MachODump.cpp?rev=313146&r1=313145&r2=313146&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/MachODump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/MachODump.cpp Wed Sep 13 06:57:45 2017
@@ -5881,7 +5881,9 @@ static void PrintXarFilesSummary(const c
if(name != nullptr)
outs() << name;
outs() << "\n";
+ xar_iter_free(xp);
}
+ xar_iter_free(xi);
}
static void DumpBitcodeSection(MachOObjectFile *O, const char *sect,
@@ -6044,7 +6046,7 @@ static void DumpBitcodeSection(MachOObje
char *endptr;
member_size = strtoul(member_size_string, &endptr, 10);
if (*endptr == '\0' && member_size != 0) {
- char *buffer = (char *)::operator new(member_size);
+ char *buffer;
if (xar_extract_tobuffersz(xar, xf, &buffer, &member_size) == 0) {
#if 0 // Useful for debugging.
outs() << "xar member: " << member_name << " extracted\n";
@@ -6075,12 +6077,13 @@ static void DumpBitcodeSection(MachOObje
XarMemberName);
}
XarMemberName = OldXarMemberName;
+ delete buffer;
}
- delete buffer;
}
}
xar_iter_free(xp);
}
+ xar_iter_free(xi);
xar_close(xar);
}
#endif // defined(HAVE_LIBXAR)
More information about the llvm-commits
mailing list