summaryrefslogtreecommitdiff
path: root/oox/source
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-03-20 22:57:17 -0400
committerCaolán McNamara <caolanm@redhat.com>2018-03-22 09:51:55 +0100
commitf82888653c853f236ab0035bb578a7129ec72fa5 (patch)
treecf315186c80a5321c0fa64ff3221d4787f8a7e2b /oox/source
parentf3e8d0fb317090aade384784a1e16a8c8afe3437 (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>
Diffstat (limited to 'oox/source')
-rw-r--r--oox/source/core/xmlfilterbase.cxx15
1 files changed, 9 insertions, 6 deletions
diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx
index 00d202b315da..58333fb6c229 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -1118,13 +1118,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));
+ }
}
}
}