diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2018-03-20 22:57:17 -0400 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2018-04-05 11:09:52 +0200 |
commit | 8556df333ee23daf918ec50ce675369e3466380f (patch) | |
tree | ac7d3a5670063c03951641e844c5b5554ddd7a53 /oox | |
parent | 6540f3f780fa200afea1e50c280a13918c7a07a1 (diff) |
oox: don't segfault when failing to open a custom fragment
Change-Id: Ie05d1feea2e930b117b3754c6e0db86bdb85bc61
Reviewed-on: https://gerrit.libreoffice.org/51681
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
(cherry picked from commit f82888653c853f236ab0035bb578a7129ec72fa5)
Reviewed-on: https://gerrit.libreoffice.org/52228
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Tested-by: Jan Holesovsky <kendy@collabora.com>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/core/xmlfilterbase.cxx | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx index 873991a8f998..39a5858ae642 100644 --- a/oox/source/core/xmlfilterbase.cxx +++ b/oox/source/core/xmlfilterbase.cxx @@ -1119,13 +1119,16 @@ void XmlFilterBase::exportCustomFragments() addRelation(customFragmentTypes[j], customFragmentTargets[j]); const OUString aFilename = customFragmentTargets[j]; Reference<XOutputStream> xOutStream = openOutputStream(aFilename); - xOutStream->writeBytes(customFragments[j]); - uno::Reference<XPropertySet> xProps(xOutStream, uno::UNO_QUERY); - if (xProps.is()) + if (xOutStream.is()) { - const OUString aType = comphelper::OFOPXMLHelper::GetContentTypeByName(aContentTypes, aFilename); - const OUString aContentType = (aType.getLength() ? aType : OUString("application/octet-stream")); - xProps->setPropertyValue("MediaType", uno::makeAny(aContentType)); + xOutStream->writeBytes(customFragments[j]); + uno::Reference<XPropertySet> xProps(xOutStream, uno::UNO_QUERY); + if (xProps.is()) + { + const OUString aType = comphelper::OFOPXMLHelper::GetContentTypeByName(aContentTypes, aFilename); + const OUString aContentType = (aType.getLength() ? aType : OUString("application/octet-stream")); + xProps->setPropertyValue("MediaType", uno::makeAny(aContentType)); + } } } } |