Skip to content

Commit a0414d6

Browse files
committed
Issue #656 - protect against NULL node set in loop
1 parent f0438bd commit a0414d6

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)