diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2023-11-26 00:23:39 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2023-11-26 18:17:07 +0100 |
commit | ef79b9c55828d39de3d86cedd125f2f32e6b259a (patch) | |
tree | 49b5732d4373d7358087cb6fe6b03e8af63386b2 | |
parent | 872d26d4a859ff72e1e13068b798854185960de0 (diff) |
*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.kaganski@collabora.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r-- | sfx2/source/doc/docfile.cxx | 36 |
1 files changed, 16 insertions, 20 deletions
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& ) {} |