From: Jouni Malinen Date: Wed, 16 Mar 2016 19:49:28 +0000 (+0200) Subject: libxml2: Check for xmlDocDumpFormatMemory() error case X-Git-Tag: hostap_2_6~713 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=64ce5905f85fc9db2ff66e1d2e0e0355092ced02;p=thirdparty%2Fhostap.git 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 --- diff --git a/src/utils/xml_libxml2.c b/src/utils/xml_libxml2.c index c92839461..7b6d2764b 100644 --- a/src/utils/xml_libxml2.c +++ b/src/utils/xml_libxml2.c @@ -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, "');