unotools/source/ucbhelper/tempfile.cxx |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

New commits:
commit c33607813ad0c4de69d20b98ba6146f319443d66
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Wed Oct 19 10:24:27 2022 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Wed Oct 19 13:09:35 2022 +0200

    crashtesting: temp files accumulating over time
    
    Change-Id: I922ba92d0a9278b366b4bec38170a776830c1682
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141525
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/unotools/source/ucbhelper/tempfile.cxx 
b/unotools/source/ucbhelper/tempfile.cxx
index af58473b9b87..406f08130dbd 100644
--- a/unotools/source/ucbhelper/tempfile.cxx
+++ b/unotools/source/ucbhelper/tempfile.cxx
@@ -368,6 +368,7 @@ TempFileFast::TempFileFast(TempFileFast && other) noexcept :
 
 TempFileFast::~TempFileFast()
 {
+    CloseStream();
 }
 
 SvStream* TempFileFast::GetStream( StreamMode eMode )
@@ -382,7 +383,13 @@ SvStream* TempFileFast::GetStream( StreamMode eMode )
 
 void TempFileFast::CloseStream()
 {
-    mxStream.reset();
+    if (mxStream)
+    {
+        OUString aName = mxStream->GetFileName();
+        mxStream.reset();
+        if (!aName.isEmpty() && 
(osl::FileBase::getFileURLFromSystemPath(aName, aName) == 
osl::FileBase::E_None))
+            File::remove(aName);
+    }
 }
 
 OUString CreateTempURL( const OUString* pParent, bool bDirectory )

Reply via email to