libxml2: Check for xmlDocDumpFormatMemory() error case
Since this function needs to allocate memory, it might fail. Check that the returned memory pointer is not NULL before trying to parse the output. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
parent
8b827c342f
commit
64ce5905f8
1 changed files with 2 additions and 0 deletions
|
@ -212,6 +212,8 @@ char * xml_node_to_str(struct xml_node_ctx *ctx, xml_node_t *node)
|
|||
xmlDocSetRootElement(doc, n);
|
||||
xmlDocDumpFormatMemory(doc, &buf, &bufsiz, 0);
|
||||
xmlFreeDoc(doc);
|
||||
if (!buf)
|
||||
return NULL;
|
||||
pos = (char *) buf;
|
||||
if (strncmp(pos, "<?xml", 5) == 0) {
|
||||
pos = strchr(pos, '>');
|
||||
|
|
Loading…
Reference in a new issue