Protext agains a NULL node in the Debug only code

This commit is contained in:
Geoff McLane 2015-09-12 13:06:14 +02:00
parent 6ebd527750
commit 9960f7c6dd

View file

@ -91,8 +91,8 @@ static void Show_Node( TidyDocImpl* doc, const char *msg, Node *node )
} }
if (lexer && lexer->token && (lexer->token->type == TextNode)) { if (lexer && lexer->token && (lexer->token->type == TextNode)) {
if (show_attrs) { if (show_attrs) {
uint len = node->end - node->start; uint len = node ? node->end - node->start : 0;
tmbstr cp = get_text_string( lexer, node ); tmbstr cp = node ? get_text_string( lexer, node ) : "NULL";
SPRTF("Returning %s TextNode [%s]%u %s\n", msg, cp, len, SPRTF("Returning %s TextNode [%s]%u %s\n", msg, cp, len,
lex ? "lexer" : "stream"); lex ? "lexer" : "stream");
} else { } else {
@ -102,8 +102,9 @@ static void Show_Node( TidyDocImpl* doc, const char *msg, Node *node )
} else { } else {
if (show_attrs) { if (show_attrs) {
AttVal* av; AttVal* av;
tmbstr name = node->element ? node->element : "blank"; tmbstr name = node ? node->element ? node->element : "blank" : "NULL";
SPRTF("Returning %s node <%s", msg, name); SPRTF("Returning %s node <%s", msg, name);
if (node) {
for (av = node->attributes; av; av = av->next) { for (av = node->attributes; av; av = av->next) {
name = av->attribute; name = av->attribute;
if (name) { if (name) {
@ -113,6 +114,7 @@ static void Show_Node( TidyDocImpl* doc, const char *msg, Node *node )
} }
} }
} }
}
SPRTF("> %s\n", lex ? "lexer" : "stream"); SPRTF("> %s\n", lex ? "lexer" : "stream");
} else { } else {
SPRTF("Returning %s node %p <%s>... %s\n", msg, node, SPRTF("Returning %s node %p <%s>... %s\n", msg, node,