[PATCH] D37750: [llvm-objdump] Fix memory leaks in macho dump
Francis Ricci via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 13 06:57:49 PDT 2017
fjricci updated this revision to Diff 115035.
fjricci added a comment.
Only delete buffer if `xar_extract_tobuffersz` succeeds
https://reviews.llvm.org/D37750
Files:
tools/llvm-objdump/MachODump.cpp
Index: tools/llvm-objdump/MachODump.cpp
===================================================================
--- tools/llvm-objdump/MachODump.cpp
+++ tools/llvm-objdump/MachODump.cpp
@@ -5881,7 +5881,9 @@
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 @@
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 @@
XarMemberName);
}
XarMemberName = OldXarMemberName;
+ delete buffer;
}
- delete buffer;
}
}
xar_iter_free(xp);
}
+ xar_iter_free(xi);
xar_close(xar);
}
#endif // defined(HAVE_LIBXAR)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37750.115035.patch
Type: text/x-patch
Size: 1124 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170913/237612ce/attachment.bin>
More information about the llvm-commits
mailing list