[glom/glom-1-22] Initial dialog: Fix crash with latest libxml.



commit 6f01d7d8f79cd127418c2a4b234de670225fb71a
Author: Murray Cumming <murrayc murrayc com>
Date:   Thu Jul 18 21:18:52 2013 +0200

    Initial dialog: Fix crash with latest libxml.
    
        * glom/dialog_existing_or_new.cc: Catch exceptions from
        xmlpp::SaxParser::parse_chunk() because libxml nows
        returns an error code from xmlParserChunk when we call
        xmlStopParser(), which libxml++ then throws as an
        exception. Maybe libxml++ should not do that for that
        new error code.
        This is the libxml commit:
        https://git.gnome.org/browse/libxml2/commit/?id=e50ba8164eee06461c73cd8abb9b46aa0be81869

 ChangeLog                      |   13 +++++++++++++
 glom/dialog_existing_or_new.cc |   12 +++++++++++-
 2 files changed, 24 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 67b8127..615d32c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2013-07-18  Murray Cumming  <murrayc murrayc com>
+
+       Initial dialog: Fix crash with latest libxml.
+
+       * glom/dialog_existing_or_new.cc: Catch exceptions from
+       xmlpp::SaxParser::parse_chunk() because libxml nows
+       returns an error code from xmlParserChunk when we call
+       xmlStopParser(), which libxml++ then throws as an
+       exception. Maybe libxml++ should not do that for that
+       new error code.
+       This is the libxml commit:
+       https://git.gnome.org/browse/libxml2/commit/?id=e50ba8164eee06461c73cd8abb9b46aa0be81869
+
 2013-06-10  Murray Cumming  <murrayc murrayc com>
 
        Initial dialog: Fix the notebook vertical expansion.
diff --git a/glom/dialog_existing_or_new.cc b/glom/dialog_existing_or_new.cc
index ddaf383..dba262b 100644
--- a/glom/dialog_existing_or_new.cc
+++ b/glom/dialog_existing_or_new.cc
@@ -64,7 +64,17 @@ public:
 
   Glib::ustring get_example_title(const std::string& beginning)
   {
-    parse_chunk(beginning);
+    try
+    {
+      parse_chunk(beginning);
+    }
+    catch(const xmlpp::exception& /* ex */)
+    {
+      //Ignore these, returning as much of the title as we have managed to retrieve.
+      //Recent versions of libxml now cause an exception after we call xmlStopParser() anyway.
+      //TODO: How can we get the error code from the exception anyway?
+    }
+
     return m_title;
   }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]