Package: tidy-html5 / 1:5.2.0-2

upstream_Avoid-crash-in-tidyCleanAndRepair-if-document-was-no.patch Patch series | download
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
From 10281040ca6b3a54db7880eed9c67957d11622eb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= <michal@cihar.com>
Date: Wed, 29 Jun 2016 16:11:10 +0200
Subject: [PATCH] Avoid crash in tidyCleanAndRepair if document was not loaded

These services can only be used when there is a document loaded, ie a
lexer created.  But really should not be calling a Clean and Repair
service with no doc!
---
 src/tidylib.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/tidylib.c b/src/tidylib.c
index 28ebbb2..4787336 100755
--- a/src/tidylib.c
+++ b/src/tidylib.c
@@ -1908,9 +1908,18 @@ int         tidyDocCleanAndRepair( TidyDocImpl* doc )
        it can ever be, so we can start detecting things that shouldn't
        be in this version of HTML
      */
-    if (doc->lexer->versionEmitted & VERS_HTML5)
-         TY_(CheckHTML5)( doc, &doc->root );
-    TY_(CheckHTMLTagsAttribsVersions)( doc, &doc->root );
+    if (doc->lexer) 
+    {
+        /*\ 
+         *  Issue #429 #426 - These services can only be used
+         *  when there is a document loaded, ie a lexer created.
+         *  But really should not be calling a Clean and Repair
+         *  service with no doc!
+        \*/
+        if (doc->lexer->versionEmitted & VERS_HTML5)
+            TY_(CheckHTML5)( doc, &doc->root );
+        TY_(CheckHTMLTagsAttribsVersions)( doc, &doc->root );
+    }
 
 #if !defined(NDEBUG) && defined(_MSC_VER)
     SPRTF("All nodes AFTER clean and repair\n");
-- 
2.8.1