From 2badcbb6743ff803c9cd82db77a1d8a50802058f Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Tue, 14 Apr 2015 19:11:26 -0700 Subject: Explicitly call xml_buffered_writer::flush() If xml_writer::write throws an exception while being called from flush(), the exception is thrown from destructor. Clang in C++11 mode calls std::terminate in this case. --- src/pugixml.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/pugixml.cpp b/src/pugixml.cpp index 590d07f..1c1b539 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -3115,11 +3115,6 @@ PUGI__NS_BEGIN PUGI__STATIC_ASSERT(bufcapacity >= 8); } - ~xml_buffered_writer() - { - flush(); - } - size_t flush() { flush(buffer, bufsize); @@ -5496,6 +5491,8 @@ namespace pugi impl::xml_buffered_writer buffered_writer(writer, encoding); impl::node_output(buffered_writer, _root, indent, flags, depth); + + buffered_writer.flush(); } #ifndef PUGIXML_NO_STL @@ -6205,6 +6202,8 @@ namespace pugi } impl::node_output(buffered_writer, _root, indent, flags, 0); + + buffered_writer.flush(); } #ifndef PUGIXML_NO_STL -- cgit v1.2.3