Issue #656 - protect against NULL node set in loop

This commit is contained in:
Geoff McLane 2017-12-16 20:54:29 +01:00
parent f0438bd4b8
commit a0414d65a6

View file

@ -2211,8 +2211,10 @@ Bool TY_(TidyMetaCharset)(TidyDocImpl* doc)
tidyBufAppend(&charsetString, "charset=", 8); tidyBufAppend(&charsetString, "charset=", 8);
tidyBufAppend(&charsetString, (char*)enc, TY_(tmbstrlen)(enc)); tidyBufAppend(&charsetString, (char*)enc, TY_(tmbstrlen)(enc));
tidyBufAppend(&charsetString, "\0", 1); /* zero terminate the buffer */ tidyBufAppend(&charsetString, "\0", 1); /* zero terminate the buffer */
/* process the children of the head */ /* process the children of the head */
for (currentNode = head->content; currentNode; currentNode = currentNode->next) /* Issue #656 - guard against 'currentNode' being set NULL in loop */
for (currentNode = head->content; currentNode;
currentNode = (currentNode ? currentNode->next : NULL))
{ {
if (!nodeIsMETA(currentNode)) if (!nodeIsMETA(currentNode))
continue; /* not a meta node */ continue; /* not a meta node */