From a55796be911334f5a02f7407af1b6b6bb5219b53 Mon Sep 17 00:00:00 2001 From: Ary Borenszweig Date: Fri, 22 Feb 2019 15:22:20 -0300 Subject: [PATCH] XML: workaround for bug in libxml2 2.9.9 --- src/xml/reader.cr | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/xml/reader.cr b/src/xml/reader.cr index 2564180b8c82..f9e5278119a0 100644 --- a/src/xml/reader.cr +++ b/src/xml/reader.cr @@ -129,6 +129,16 @@ struct XML::Reader # Returns the XML for the node and its content including subtrees. def read_outer_xml + # On a NONE type libxml2 2.9.9 is giving a segfault: + # + # https://gitlab.gnome.org/GNOME/libxml2/issues/43 + # + # so we avoid the issue by returning early here. + # + # FIXME: if that issue is fixed we should revert this line + # to avoid doing an extra C call each time. + return "" if node_type.none? + xml = LibXML.xmlTextReaderReadOuterXml(@reader) xml ? String.new(xml) : "" end