[PATCH] D148002: draft fix mem leak in WindowsManifestMerger.cpp
Wang, Xin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 11 03:11:37 PDT 2023
XinWang10 created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
XinWang10 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D148002
Files:
llvm/lib/WindowsManifest/WindowsManifestMerger.cpp
Index: llvm/lib/WindowsManifest/WindowsManifestMerger.cpp
===================================================================
--- llvm/lib/WindowsManifest/WindowsManifestMerger.cpp
+++ llvm/lib/WindowsManifest/WindowsManifestMerger.cpp
@@ -348,6 +348,8 @@
NewDefinedDefaultHref = TO_XML_CHAR(strdup(FROM_XML_CHAR(Def->href)));
}
} else if (!xmlStringsEqual(OriginalNsDef->href, Def->href)) {
+ if (NewDefinedDefaultHref)
+ xmlFree(const_cast<unsigned char *>(NewDefinedDefaultHref));
return make_error<WindowsManifestError>(
Twine("conflicting namespace definitions for ") +
FROM_XML_CHAR(Def->prefix));
@@ -382,6 +384,9 @@
Expected<xmlNsPtr> EC =
searchOrDefine(OriginalDefinedDefaultHref, DominantNode);
if (!EC) {
+ xmlFree(const_cast<unsigned char *>(OriginalDefinedDefaultHref));
+ if (NewDefinedDefaultHref)
+ xmlFree(const_cast<unsigned char *>(NewDefinedDefaultHref));
return EC.takeError();
}
xmlNsPtr PrefixDominantDefinedDefault = std::move(EC.get());
@@ -420,6 +425,10 @@
Expected<xmlNsPtr> EC =
searchOrDefine(DominantNode->ns->href, NonDominantNode);
if (!EC) {
+ if (OriginalDefinedDefaultHref)
+ xmlFree(const_cast<unsigned char *>(OriginalDefinedDefaultHref));
+ if (NewDefinedDefaultHref)
+ xmlFree(const_cast<unsigned char *>(NewDefinedDefaultHref));
return EC.takeError();
}
xmlNsPtr Explicit = std::move(EC.get());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148002.512382.patch
Type: text/x-patch
Size: 1583 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230411/c40349e1/attachment.bin>
More information about the llvm-commits
mailing list