From fd0ccb2bbf3f907e5425d5849409fbf1558197bc Mon Sep 17 00:00:00 2001 From: Geoff McLane Date: Sun, 30 Oct 2016 23:37:31 +0100 Subject: [PATCH] Bad, repeated node iteration! closes #459 --- src/parser.c | 10 +++++++++- version.txt | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/parser.c b/src/parser.c index 4fb7a8c..30a9911 100644 --- a/src/parser.c +++ b/src/parser.c @@ -3851,7 +3851,15 @@ Bool TY_(FindNodeWithId)( Node *node, TidyTagId tid ) { if (TagIsId(node,tid)) return yes; - for (content = node->content; content; content = content->content) + /*\ + * Issue #459 - Under certain circumstances, with many node this use of + * 'for (content = node->content; content; content = content->content)' + * would produce a **forever** circle, or at least a very extended loop... + * It is sufficient to test the content, if it exists, + * to quickly iterate all nodes. Now all nodes are tested only once. + \*/ + content = node->content; + if (content) { if (TY_(FindNodeWithId)(content,tid)) return yes; diff --git a/version.txt b/version.txt index 9c3783d..f9c3f12 100644 --- a/version.txt +++ b/version.txt @@ -1,2 +1,2 @@ -5.3.11 -2016.09.11 +5.3.12 +2016.10.14