summaryrefslogtreecommitdiff
path: root/debian/patches/0045-Add-couple-of-missing-Null-checks.patch
blob: 29d8523cf099dc1f23aac530a2a3dd3795c47994 (plain)
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
42
43
44
45
46
47
48
49
From: Daniel Veillard <veillard@redhat.com>
Date: Sat, 26 Jul 2014 21:04:54 +0800
Subject: Add couple of missing Null checks

For https://bugzilla.gnome.org/show_bug.cgi?id=733710
Reported by Gaurav but with slightly different fixes
---
 relaxng.c | 7 ++++++-
 tree.c    | 4 ++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/relaxng.c b/relaxng.c
index 33fc71a..936f657 100644
--- a/relaxng.c
+++ b/relaxng.c
@@ -6655,12 +6655,17 @@ xmlRelaxNGParseDocument(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node)
     ctxt->define = NULL;
     if (IS_RELAXNG(node, "grammar")) {
         schema->topgrammar = xmlRelaxNGParseGrammar(ctxt, node->children);
+        if (schema->topgrammar == NULL) {
+            xmlRelaxNGFree(schema);
+            return (NULL);
+        }
     } else {
         xmlRelaxNGGrammarPtr tmp, ret;
 
         schema->topgrammar = ret = xmlRelaxNGNewGrammar(ctxt);
         if (schema->topgrammar == NULL) {
-            return (schema);
+            xmlRelaxNGFree(schema);
+            return (NULL);
         }
         /*
          * Link the new grammar in the tree
diff --git a/tree.c b/tree.c
index 43c3c57..967c6a4 100644
--- a/tree.c
+++ b/tree.c
@@ -4509,6 +4509,10 @@ xmlCopyDoc(xmlDocPtr doc, int recursive) {
 #ifdef LIBXML_TREE_ENABLED
     if (doc->intSubset != NULL) {
         ret->intSubset = xmlCopyDtd(doc->intSubset);
+	if (ret->intSubset == NULL) {
+	    xmlFreeDoc(ret);
+	    return(NULL);
+	}
 	xmlSetTreeDoc((xmlNodePtr)ret->intSubset, ret);
 	ret->intSubset->parent = ret;
     }