[Lldb-commits] [PATCH] D116707: [lldb] fix memory leak in "GetGDBServerRegisterInfoXMLAndProcess"
Lirong Yuan via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Thu Jan 6 15:53:08 PST 2022
yuanzi updated this revision to Diff 398009.
yuanzi edited the summary of this revision.
yuanzi added a comment.
Yeah since `xmlGetProp` calls `xmlGetPropNodeValueInternal`, which calls `xmlStrdup` rather than returning the content or value of the node directly, `xmlFreeDoc` could not clean it up.
https://github.com/tenderlove/libxml2/blob/master/tree.c
Agree that we need to update the API to return not just a reference to string (`llvm::StringRef`), but an object that can own string data (`std::string`).
This change fixes the memory leaks in "GetGDBServerRegisterInfoXMLAndProcess" by updating "GetAttributeValue" to return "std::string" instead of "llvm::StringRef".
Tested with "ninja check-lldb".
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D116707/new/
https://reviews.llvm.org/D116707
Files:
lldb/include/lldb/Host/XML.h
lldb/source/Host/common/XML.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116707.398009.patch
Type: text/x-patch
Size: 5071 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220106/bfcf0eef/attachment-0001.bin>
More information about the lldb-commits
mailing list