Skip to content

Commit a111d7a

Browse files
authored
Merge pull request #661 from htacg/issue-656
Issue #656 - protect against NULL node set in loop - closes #656
2 parents f0438bd + a0414d6 commit a111d7a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/clean.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -2211,8 +2211,10 @@ Bool TY_(TidyMetaCharset)(TidyDocImpl* doc)
22112211
tidyBufAppend(&charsetString, "charset=", 8);
22122212
tidyBufAppend(&charsetString, (char*)enc, TY_(tmbstrlen)(enc));
22132213
tidyBufAppend(&charsetString, "\0", 1); /* zero terminate the buffer */
2214-
/* process the children of the head */
2215-
for (currentNode = head->content; currentNode; currentNode = currentNode->next)
2214+
/* process the children of the head */
2215+
/* Issue #656 - guard against 'currentNode' being set NULL in loop */
2216+
for (currentNode = head->content; currentNode;
2217+
currentNode = (currentNode ? currentNode->next : NULL))
22162218
{
22172219
if (!nodeIsMETA(currentNode))
22182220
continue; /* not a meta node */

0 commit comments

Comments
 (0)