[PATCH] D148002: Fix mem leak in WindowsManifestMerger.cpp
Wang, Xin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 11 19:43:07 PDT 2023
XinWang10 updated this revision to Diff 512641.
XinWang10 added a comment.
- add the missing one
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D148002/new/
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());
@@ -400,6 +405,8 @@
Expected<xmlNsPtr> EC =
searchOrDefine(ClosestDefault->href, DominantNode);
if (!EC) {
+ if (NewDefinedDefaultHref)
+ xmlFree(const_cast<unsigned char *>(NewDefinedDefaultHref));
return EC.takeError();
}
xmlNsPtr ExplicitDefault = std::move(EC.get());
@@ -420,6 +427,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.512641.patch
Type: text/x-patch
Size: 1935 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230412/d6aeafb5/attachment.bin>
More information about the llvm-commits
mailing list