File: 0003-Issue-656-protect-against-NULL-node-set-in-loop.patch

package info (click to toggle)
tidy-html5 2%3A5.6.0-10
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 5,508 kB
  • sloc: ansic: 40,477; ruby: 841; sh: 293; makefile: 30; cpp: 30
file content (25 lines) | stat: -rw-r--r-- 1,087 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
From: Geoff McLane <ubuntu@geoffair.info>
Date: Sat, 16 Dec 2017 20:54:29 +0100
Subject: Issue #656 - protect against NULL node set in loop

---
 src/clean.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

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