]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
libxml2: Check for xmlDocDumpFormatMemory() error case
authorJouni Malinen <jouni@qca.qualcomm.com>
Wed, 16 Mar 2016 19:49:28 +0000 (21:49 +0200)
committerJouni Malinen <j@w1.fi>
Wed, 16 Mar 2016 19:49:28 +0000 (21:49 +0200)
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>
src/utils/xml_libxml2.c

index c92839461dad4c8fc73ff9ba47b60eecd7808add..7b6d2764b0ed2f0ab24ee65dc6fb1e4a32773cc2 100644 (file)
@@ -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, '>');