[glom] Initial dialog: Fix crash with latest libxml.



commit d66caa663b944e7af29aaef7cf9dfc8722385412
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 efa6dee..9b94067 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 7f0c3e2..4bf6298 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]