Line 0
Link Here
|
|
|
1 |
# https://github.com/itstool/itstool/pull/18 |
2 |
# https://github.com/itstool/itstool/issues/17 |
3 |
|
4 |
From 98d04cdabf1721cb541ecd234c975f13fde4fa41 Mon Sep 17 00:00:00 2001 |
5 |
From: Guido Trentalancia <guido@trentalancia.com> |
6 |
Date: Wed, 1 Nov 2017 18:20:36 +0100 |
7 |
Subject: [PATCH 1/2] Revert "Be more careful about libxml2 memory management" |
8 |
|
9 |
This reverts commit 9b84c007a73e8275ca45762f1bfa3ab7c3a852e2. |
10 |
--- |
11 |
itstool.in | 13 ++----------- |
12 |
1 file changed, 2 insertions(+), 11 deletions(-) |
13 |
|
14 |
diff --git itstool.in itstool.in |
15 |
index a16eba9..c1d0585 100755 |
16 |
--- itstool.in |
17 |
+++ itstool.in |
18 |
@@ -477,7 +477,6 @@ class Document (object): |
19 |
if load_dtd: |
20 |
ctxt.loadSubset(1) |
21 |
if keep_entities: |
22 |
- ctxt.loadSubset(1) |
23 |
ctxt.ctxtUseOptions(libxml2.XML_PARSE_DTDLOAD) |
24 |
ctxt.replaceEntities(0) |
25 |
else: |
26 |
@@ -1044,7 +1043,6 @@ class Document (object): |
27 |
if self._load_dtd: |
28 |
ctxt.loadSubset(1) |
29 |
if self._keep_entities: |
30 |
- ctxt.loadSubset(1) |
31 |
ctxt.ctxtUseOptions(libxml2.XML_PARSE_DTDLOAD) |
32 |
ctxt.replaceEntities(0) |
33 |
else: |
34 |
@@ -1071,9 +1069,7 @@ class Document (object): |
35 |
ph_node = msg.get_placeholder(child.name).node |
36 |
if self.has_child_elements(ph_node): |
37 |
self.merge_translations(translations, None, ph_node, strict=strict) |
38 |
- newnode = ph_node.copyNode(1) |
39 |
- newnode.setTreeDoc(self._doc) |
40 |
- child.replaceNode(newnode) |
41 |
+ child.replaceNode(ph_node) |
42 |
else: |
43 |
repl = self.get_translated(ph_node, translations, strict=strict, lang=lang) |
44 |
child.replaceNode(repl) |
45 |
@@ -1088,15 +1084,10 @@ class Document (object): |
46 |
(lang + ' ') if lang is not None else '', |
47 |
msgstr.encode('utf-8'))) |
48 |
self._xml_err = '' |
49 |
- ctxt.doc().freeDoc() |
50 |
return node |
51 |
retnode = node.copyNode(2) |
52 |
- retnode.setTreeDoc(self._doc) |
53 |
for child in xml_child_iter(trnode): |
54 |
- newnode = child.copyNode(1) |
55 |
- newnode.setTreeDoc(self._doc) |
56 |
- retnode.addChild(newnode) |
57 |
- |
58 |
+ retnode.addChild(child.copyNode(1)) |
59 |
ctxt.doc().freeDoc() |
60 |
return retnode |
61 |
|
62 |
|
63 |
From 1549b6d12eb2f35e5c7f1b1856c21768e92ba794 Mon Sep 17 00:00:00 2001 |
64 |
From: Guido Trentalancia <guido@trentalancia.com> |
65 |
Date: Wed, 1 Nov 2017 18:23:44 +0100 |
66 |
Subject: [PATCH 2/2] Fix a segmentation fault bug introduced with version |
67 |
2.0.4. |
68 |
|
69 |
https://github.com/itstool/itstool/issues/17 |
70 |
|
71 |
This fix seems a lot easier than the previous reverted commit. |
72 |
--- |
73 |
itstool.in | 2 +- |
74 |
1 file changed, 1 insertion(+), 1 deletion(-) |
75 |
|
76 |
diff --git itstool.in itstool.in |
77 |
index c1d0585..e492e95 100755 |
78 |
--- itstool.in |
79 |
+++ itstool.in |
80 |
@@ -1048,7 +1048,7 @@ class Document (object): |
81 |
else: |
82 |
ctxt.replaceEntities(1) |
83 |
ctxt.parseDocument() |
84 |
- trnode = ctxt.doc().getRootElement() |
85 |
+ trnode = ctxt.doc().getRootElement().copyNode(1) |
86 |
try: |
87 |
self._check_errors() |
88 |
except libxml2.parserError: |