diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-10-11 10:45:40 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2022-10-12 09:52:15 +0200 |
commit | 06423ddc61a378894c91a6a23fb31afb1701d8f2 (patch) | |
tree | deb6ad0b2212885c263b58849652e87cb2e0cb06 /sax | |
parent | 56b8703d6f759326f7ac1a84ca0e6d1c9b40aad7 (diff) |
crashtesting: exception during dtor
Change-Id: I9874778ba79540cfde32bf59c3a63ebb72889dc7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141215
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sax')
-rw-r--r-- | sax/source/tools/fshelper.cxx | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/sax/source/tools/fshelper.cxx b/sax/source/tools/fshelper.cxx index 7cbd3c36abc1..fbf7f0672709 100644 --- a/sax/source/tools/fshelper.cxx +++ b/sax/source/tools/fshelper.cxx @@ -17,6 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/log.hxx> #include <sax/fshelper.hxx> #include "fastserializer.hxx" @@ -29,12 +30,27 @@ FastSerializerHelper::FastSerializerHelper(const Reference< io::XOutputStream >& mpSerializer(new FastSaxSerializer(xOutputStream)) { if( bWriteHeader ) - mpSerializer->startDocument(); + startDocument(); +} + +void FastSerializerHelper::startDocument() +{ + mpSerializer->startDocument(); +} + +void FastSerializerHelper::endDocument() +{ + std::unique_ptr<FastSaxSerializer> xSerializer(std::move(mpSerializer)); + xSerializer->endDocument(); } FastSerializerHelper::~FastSerializerHelper() { - mpSerializer->endDocument(); + if (mpSerializer) + { + assert(false && "call endDocument explicitly before dtor to avoid potential exceptions during dtor"); + endDocument(); + } } void FastSerializerHelper::startElement(sal_Int32 elementTokenId) |