diff options
author | Vincent Sanders <vince@kyllikki.org> | 2016-08-24 22:52:12 +0100 |
---|---|---|
committer | Vincent Sanders <vince@kyllikki.org> | 2016-08-24 22:52:12 +0100 |
commit | b9b81b9b8a34f5b3a9069c111c4d7530d73a04ce (patch) | |
tree | 168a0dfce6ae62979a451d459ef8c5f1c6ff3854 /bindings | |
parent | d055eaf25d60a1c1538bacc32d5e51a073477ebb (diff) | |
download | libdom-b9b81b9b8a34f5b3a9069c111c4d7530d73a04ce.tar.gz libdom-b9b81b9b8a34f5b3a9069c111c4d7530d73a04ce.tar.bz2 |
protect expat parser from null current node
Diffstat (limited to 'bindings')
-rw-r--r-- | bindings/xml/expat_xmlparser.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/bindings/xml/expat_xmlparser.c b/bindings/xml/expat_xmlparser.c index e1c22ad..4bdd5c9 100644 --- a/bindings/xml/expat_xmlparser.c +++ b/bindings/xml/expat_xmlparser.c @@ -45,6 +45,11 @@ expat_xmlparser_start_element_handler(void *_parser, dom_string *namespace = NULL; const XML_Char *ns_sep = strchr(name, '\n'); + if (parser->current == NULL) { + /* not currently building a node so cannot add elemnt to it */ + return; + } + if (ns_sep != NULL) { err = dom_string_create_interned((const uint8_t *)name, ns_sep - name, @@ -174,6 +179,13 @@ expat_xmlparser_end_element_handler(void *_parser, UNUSED(name); + if (parser->current == NULL) { + /* not currently building a node so cannot end elemnt + * addition to it. + */ + return; + } + err = dom_node_get_parent_node(parser->current, &parent); if (err != DOM_NO_ERR) { @@ -213,6 +225,11 @@ expat_xmlparser_cdata_handler(void *_parser, struct dom_node *cdata, *ins_cdata, *lastchild = NULL; dom_node_type ntype = 0; + if (parser->current == NULL) { + /* not currently building a node so cannot add cdata to it */ + return; + } + err = dom_string_create((const uint8_t *)s, len, &data); if (err != DOM_NO_ERR) { parser->msg(DOM_MSG_CRITICAL, parser->mctx, |