mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-21 20:15:17 +00:00
virxml: Fix possible memory leak in virXMLNodeContentString()
Previously, if xml node passed to the virXMLNodeContentString() was not of type XML_ELEMENT_NODE, @ret could have caused a memory leak because xmlNodeGetContent() works for other types of nodes as well. Signed-off-by: Kristina Hanicova <khanicov@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
4d09f35f57
commit
aaa98e3cfa
@ -536,7 +536,7 @@ virXMLPropStringLimit(xmlNodePtr node,
|
||||
char *
|
||||
virXMLNodeContentString(xmlNodePtr node)
|
||||
{
|
||||
char *ret = (char *)xmlNodeGetContent(node);
|
||||
char *ret = NULL;
|
||||
|
||||
if (node->type != XML_ELEMENT_NODE) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
@ -545,6 +545,8 @@ virXMLNodeContentString(xmlNodePtr node)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = (char *)xmlNodeGetContent(node);
|
||||
|
||||
if (!ret) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("node '%s' has unexpected NULL content. This could be caused by malformed input, or a memory allocation failure"),
|
||||
|
Loading…
x
Reference in New Issue
Block a user