sfx2/source/doc/docfile.cxx | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-)
New commits: commit ef79b9c55828d39de3d86cedd125f2f32e6b259a Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Sun Nov 26 00:23:39 2023 +0300 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Sun Nov 26 18:17:07 2023 +0100 *DocumentLockFile ctor may throw ... e.g., when passed URL is invalid, as seen after opening https://bugs.documentfoundation.org/attachment.cgi?id=121217 using "Office Open XML Text" filter, which sets "RepairPackage" in the media descriptor, which makes the opened file unnamed. Since the code is called from SfxMedium dtor, this crashed on closing this file. Change-Id: I95f6b16f1421abd55e6739ed431878bb72cf3a8e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159964 Tested-by: Mike Kaganski <mike.kagan...@collabora.com> Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index 3b975bb1add9..42fe7d72b8c5 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -3227,23 +3227,21 @@ void SfxMedium::UnlockFile( bool bReleaseLockStream ) if ( !pImpl->m_bLocked ) return; - ::svt::DocumentLockFile aLockFile( pImpl->m_aLogicName ); - try { - pImpl->m_bLocked = false; - // TODO/LATER: A warning could be shown in case the file is not the own one - aLockFile.RemoveFile(); - } - catch( const io::WrongFormatException& ) - { + ::svt::DocumentLockFile aLockFile(pImpl->m_aLogicName); + try + { + pImpl->m_bLocked = false; + // TODO/LATER: A warning could be shown in case the file is not the own one + aLockFile.RemoveFile(); + } + catch (const io::WrongFormatException&) { // erase the empty or corrupt file aLockFile.RemoveFileDirectly(); } - catch( const uno::Exception& ) - {} } catch( const uno::Exception& ) {} @@ -3251,23 +3249,21 @@ void SfxMedium::UnlockFile( bool bReleaseLockStream ) if(!pImpl->m_bMSOLockFileCreated) return; - ::svt::MSODocumentLockFile aMSOLockFile( pImpl->m_aLogicName ); - try { - pImpl->m_bLocked = false; - // TODO/LATER: A warning could be shown in case the file is not the own one - aMSOLockFile.RemoveFile(); - } - catch( const io::WrongFormatException& ) - { + ::svt::MSODocumentLockFile aMSOLockFile(pImpl->m_aLogicName); + try + { + pImpl->m_bLocked = false; + // TODO/LATER: A warning could be shown in case the file is not the own one + aMSOLockFile.RemoveFile(); + } + catch (const io::WrongFormatException&) { // erase the empty or corrupt file aMSOLockFile.RemoveFileDirectly(); } - catch( const uno::Exception& ) - {} } catch( const uno::Exception& ) {}