Merge pull request #661 from htacg/issue-656

Issue #656 - protect against NULL node set in loop - closes #656
This commit is contained in:
Geoff McLane 2018-01-01 18:15:33 +01:00 committed by GitHub
commit a111d7a969
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2212,7 +2212,9 @@ Bool TY_(TidyMetaCharset)(TidyDocImpl* doc)
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 */