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