From b8ea788aba7605233b25f14a48da1662b630e035 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 12 Oct 2015 19:51:13 +0100 Subject: Ensure the cause of the problem is logged when an htmlc has no parser. --- javascript/duktape/Document.bnd | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'javascript') diff --git a/javascript/duktape/Document.bnd b/javascript/duktape/Document.bnd index 14412cdfa..cffff88a3 100644 --- a/javascript/duktape/Document.bnd +++ b/javascript/duktape/Document.bnd @@ -38,16 +38,18 @@ method Document::write() err = dom_node_get_user_data(priv->parent.node, corestring_dom___ns_key_html_content_data, &htmlc); - if ((err == DOM_NO_ERR) && - (htmlc != NULL) && - (htmlc->parser != NULL)) { - dom_hubbub_parser_insert_chunk(htmlc->parser, - (uint8_t *)text, - text_len); - } else { + if ((err != DOM_NO_ERR) || (htmlc == NULL)) { LOG("error getting htmlc. parent node:%p htmlc:%p", - priv->parent.node, htmlc); + priv->parent.node, htmlc); + return 0; + } else if (htmlc->parser == NULL) { + LOG("error; no parser for htmlc: %p", htmlc); + return 0; } + + dom_hubbub_parser_insert_chunk(htmlc->parser, + (uint8_t *)text, text_len); + return 0; %} @@ -69,15 +71,18 @@ method Document::writeln() err = dom_node_get_user_data(priv->parent.node, corestring_dom___ns_key_html_content_data, &htmlc); - if ((err == DOM_NO_ERR) && - (htmlc != NULL) && - (htmlc->parser != NULL)) { - dom_hubbub_parser_insert_chunk(htmlc->parser, (uint8_t *)text, text_len); - dom_hubbub_parser_insert_chunk(htmlc->parser, (uint8_t *)nl, SLEN(nl)); - } else { + if ((err != DOM_NO_ERR) || (htmlc == NULL)) { LOG("error getting htmlc. parent node:%p htmlc:%p", - priv->parent.node, htmlc); + priv->parent.node, htmlc); + return 0; + } else if (htmlc->parser == NULL) { + LOG("error; no parser for htmlc: %p", htmlc); + return 0; } + + dom_hubbub_parser_insert_chunk(htmlc->parser, (uint8_t *)text, text_len); + dom_hubbub_parser_insert_chunk(htmlc->parser, (uint8_t *)nl, SLEN(nl)); + return 0; %} -- cgit v1.2.3