tdf#160192: fix crash when trying to overwrite file in RO dir+lock file
commit2887ffbf240aa70330cb50bf810170cf9c896405
authorJulien Nabet <serval2412@yahoo.fr>
Thu, 14 Mar 2024 11:20:05 +0000 (14 12:20 +0100)
committerMiklos Vajna <vmiklos@collabora.com>
Thu, 14 Mar 2024 14:33:15 +0000 (14 15:33 +0100)
tree66f3a17750a5bf4a9456c40851c267262c759f2e
parentfbb3b083d43a2e2bad19f144bca44b2f82a8938d
tdf#160192: fix crash when trying to overwrite file in RO dir+lock file

Bug exposed with:
5259ab8104cfba60c40748ed0cd59d93df038c5b
sfx2 store: create temp files next to local files

bt:
6  0x00007faac67ad9b5 in sax_fastparser::FastSaxSerializer::FastSaxSerializer(com::sun::star::uno::Reference<com::sun::star::io::XOutputStream> const&) (this=0x559f316f0e70, xOutputStream=empty uno::Reference)
    at sax/source/tools/fastserializer.cxx:68
7  0x00007faac67c46e0 in sax_fastparser::FastSerializerHelper::FastSerializerHelper(com::sun::star::uno::Reference<com::sun::star::io::XOutputStream> const&, bool)
    (this=0x559f31721400, xOutputStream=empty uno::Reference, bWriteHeader=true) at sax/source/tools/fshelper.cxx:30
8  0x00007fa9bfa1b4cc in std::_Construct<sax_fastparser::FastSerializerHelper, com::sun::star::uno::Reference<com::sun::star::io::XOutputStream>, bool const&>(sax_fastparser::FastSerializerHelper*, com::sun::star::uno::Reference<com::sun::star::io::XOutputStream>&&, bool const&) (__p=0x559f31721400, __args=..., __args=@0x7ffecd609207: true)
    at /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_construct.h:119
...
15 0x00007fa9bfa04087 in oox::core::XmlFilterBase::openFragmentStreamWithSerializer(rtl::OUString const&, rtl::OUString const&)
    (this=0x559f318ed5f0, rStreamName="docProps/core.xml", rMediaType="application/vnd.openxmlformats-package.core-properties+xml") at oox/source/core/xmlfilterbase.cxx:511
16 0x00007fa9bfa04999 in oox::core::writeCoreProperties(oox::core::XmlFilterBase&, com::sun::star::uno::Reference<com::sun::star::document::XDocumentProperties> const&)
    (rSelf=..., xProperties=uno::Reference to ((anonymous namespace)::SfxDocumentMetaData *) 0x559f2d673e28) at oox/source/core/xmlfilterbase.cxx:645
17 0x00007fa9bfa047c2 in oox::core::XmlFilterBase::exportDocumentProperties(com::sun::star::uno::Reference<com::sun::star::document::XDocumentProperties> const&, bool)
    (this=0x559f318ed5f0, xProperties=uno::Reference to ((anonymous namespace)::SfxDocumentMetaData *) 0x559f2d673e28, bSecurityOptOpenReadOnly=false) at oox/source/core/xmlfilterbase.cxx:981
18 0x00007fa9bee21bd4 in DocxExport::WriteProperties() (this=0x7ffecd609d78) at sw/source/filter/ww8/docxexport.cxx:952
19 0x00007fa9bee24b0b in DocxExport::DocxExport(DocxExportFilter&, SwDoc&, std::shared_ptr<SwUnoCursor>&, SwPaM&, bool, bool)
    (this=0x7ffecd609d78, rFilter=..., rDocument=..., pCurrentPam=std::shared_ptr<SwUnoCursor> (use count 1, weak count 1) = {...}, rOriginalPam=SwPaM = {...}, bDocm=false, bTemplate=false)
    at sw/source/filter/ww8/docxexport.cxx:2149
20 0x00007fa9bee4438e in DocxExportFilter::exportDocument() (this=0x559f318ed5f0) at sw/source/filter/ww8/docxexportfilter.cxx:112
21 0x00007fa9bf9d6b8b in oox::core::FilterBase::filter(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (this=0x559f318ed5f0, rMediaDescSeq=uno::Sequence of length 12 = {...})
    at oox/source/core/filterbase.cxx:494

full bt here:
https://bugs.documentfoundation.org/attachment.cgi?id=193113

Patch prevents LO from crashing + make LO displays error message:
Error saving the document <filename>:
Write Error.
The file could not be written

Change-Id: I41a94eeb17bb6568b586d89755bce330154d1dad
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164808
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
oox/source/core/filterbase.cxx