This is an archive of the discontinued LLVM Phabricator instance.

Fix mem leak in WindowsManifestMerger.cpp
AbandonedPublic

Authored by XinWang10 on Apr 11 2023, 3:11 AM.

Details

Summary

Code in WindowsManifestMerger.cpp could cause mem leak.
For code in function mergeNamespaces in line 330, it has 2
pointer OriginalDefinedDefaultHref and NewDefinedDefaultHref
which could point to mem which allocated by new operator,
in some branch ends with return it didn't handle them which could
be a risk.

Diff Detail

Event Timeline

XinWang10 created this revision.Apr 11 2023, 3:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 11 2023, 3:11 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
XinWang10 requested review of this revision.Apr 11 2023, 3:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 11 2023, 3:11 AM
XinWang10 retitled this revision from draft fix mem leak in WindowsManifestMerger.cpp to Fix mem leak in WindowsManifestMerger.cpp.Apr 11 2023, 6:56 PM
XinWang10 edited the summary of this revision. (Show Details)
XinWang10 updated this revision to Diff 512641.Apr 11 2023, 7:43 PM
  • add the missing one
skan added inline comments.Apr 17 2023, 12:51 AM
llvm/lib/WindowsManifest/WindowsManifestMerger.cpp
352

Do we need to free the memory when the error is taken?

XinWang10 abandoned this revision.Apr 17 2023, 1:07 AM

OK, when failed and report error mem will be freed automatically.