[packages/itstool] fix libxml2 memory management issue
jajcus
jajcus at pld-linux.org
Mon Oct 8 10:03:34 CEST 2018
commit 6f006b6b7c9fb80723f5aaef19272f0a55cb5db1
Author: Jacek Konieczny <j.konieczny at eggsoft.pl>
Date: Mon Oct 8 10:02:35 2018 +0200
fix libxml2 memory management issue
should fix crash during gtk-doc build
Release: 2
itstool.spec | 5 ++++-
libxml2_crash.patch | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 62 insertions(+), 1 deletion(-)
---
diff --git a/itstool.spec b/itstool.spec
index abc59b6..333fa5f 100644
--- a/itstool.spec
+++ b/itstool.spec
@@ -2,11 +2,12 @@ Summary: ITS-based XML translation tool
Summary(pl.UTF-8): Narzędzie do tłumaczenia XML-a oparte na ITS
Name: itstool
Version: 2.0.4
-Release: 1
+Release: 2
License: GPL v3+
Group: Applications/Text
Source0: http://files.itstool.org/itstool/%{name}-%{version}.tar.bz2
# Source0-md5: 9415ddf6a12012ff688549d2ed767bc5
+Patch0: libxml2_crash.patch
URL: http://itstool.org/
Requires: python-libxml2
BuildArch: noarch
@@ -26,6 +27,8 @@ komunikaty w pliku PO.
%prep
%setup -q
+%patch0 -p1
+
%build
%configure
%{__make}
diff --git a/libxml2_crash.patch b/libxml2_crash.patch
new file mode 100644
index 0000000..840dacc
--- /dev/null
+++ b/libxml2_crash.patch
@@ -0,0 +1,58 @@
+From 9b84c007a73e8275ca45762f1bfa3ab7c3a852e2 Mon Sep 17 00:00:00 2001
+From: Shaun McCance <shaunm at redhat.com>
+Date: Wed, 25 Oct 2017 12:10:03 -0400
+Subject: [PATCH] Be more careful about libxml2 memory management
+
+I think this fixes https://github.com/itstool/itstool/issues/17
+---
+ itstool.in | 13 +++++++++++--
+ 1 file changed, 11 insertions(+), 2 deletions(-)
+
+diff --git a/itstool.in b/itstool.in
+index c1d0585..a16eba9 100755
+--- a/itstool.in
++++ b/itstool.in
+@@ -477,6 +477,7 @@ class Document (object):
+ if load_dtd:
+ ctxt.loadSubset(1)
+ if keep_entities:
++ ctxt.loadSubset(1)
+ ctxt.ctxtUseOptions(libxml2.XML_PARSE_DTDLOAD)
+ ctxt.replaceEntities(0)
+ else:
+@@ -1043,6 +1044,7 @@ class Document (object):
+ if self._load_dtd:
+ ctxt.loadSubset(1)
+ if self._keep_entities:
++ ctxt.loadSubset(1)
+ ctxt.ctxtUseOptions(libxml2.XML_PARSE_DTDLOAD)
+ ctxt.replaceEntities(0)
+ else:
+@@ -1069,7 +1071,9 @@ class Document (object):
+ ph_node = msg.get_placeholder(child.name).node
+ if self.has_child_elements(ph_node):
+ self.merge_translations(translations, None, ph_node, strict=strict)
+- child.replaceNode(ph_node)
++ newnode = ph_node.copyNode(1)
++ newnode.setTreeDoc(self._doc)
++ child.replaceNode(newnode)
+ else:
+ repl = self.get_translated(ph_node, translations, strict=strict, lang=lang)
+ child.replaceNode(repl)
+@@ -1084,10 +1088,15 @@ class Document (object):
+ (lang + ' ') if lang is not None else '',
+ msgstr.encode('utf-8')))
+ self._xml_err = ''
++ ctxt.doc().freeDoc()
+ return node
+ retnode = node.copyNode(2)
++ retnode.setTreeDoc(self._doc)
+ for child in xml_child_iter(trnode):
+- retnode.addChild(child.copyNode(1))
++ newnode = child.copyNode(1)
++ newnode.setTreeDoc(self._doc)
++ retnode.addChild(newnode)
++
+ ctxt.doc().freeDoc()
+ return retnode
+
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/itstool.git/commitdiff/6f006b6b7c9fb80723f5aaef19272f0a55cb5db1
More information about the pld-cvs-commit
mailing list