5c8502b
From a0414d65a69927808240e41c1235145413978c43 Mon Sep 17 00:00:00 2001
5c8502b
From: Geoff McLane <ubuntu@geoffair.info>
5c8502b
Date: Sat, 16 Dec 2017 20:54:29 +0100
5c8502b
Subject: [PATCH 02/12] Issue #656 - protect against NULL node set in loop
5c8502b
5c8502b
---
5c8502b
 src/clean.c | 6 ++++--
5c8502b
 1 file changed, 4 insertions(+), 2 deletions(-)
5c8502b
5c8502b
diff --git a/src/clean.c b/src/clean.c
5c8502b
index de4caf5..e96dd3f 100644
5c8502b
--- a/src/clean.c
5c8502b
+++ b/src/clean.c
5c8502b
@@ -2211,8 +2211,10 @@ Bool TY_(TidyMetaCharset)(TidyDocImpl* doc)
5c8502b
     tidyBufAppend(&charsetString, "charset=", 8);
5c8502b
     tidyBufAppend(&charsetString, (char*)enc, TY_(tmbstrlen)(enc));
5c8502b
     tidyBufAppend(&charsetString, "\0", 1); /* zero terminate the buffer */
5c8502b
-                                            /* process the children of the head */
5c8502b
-    for (currentNode = head->content; currentNode; currentNode = currentNode->next)
5c8502b
+    /* process the children of the head */
5c8502b
+    /* Issue #656 - guard against 'currentNode' being set NULL in loop */
5c8502b
+    for (currentNode = head->content; currentNode; 
5c8502b
+        currentNode = (currentNode ? currentNode->next : NULL))
5c8502b
     {
5c8502b
         if (!nodeIsMETA(currentNode))
5c8502b
             continue;   /* not a meta node */
5c8502b
-- 
5c8502b
2.14.3
5c8502b