hwpfilter/source/htags.cxx |   26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)

New commits:
commit 231f827fabe0b4361c6e3e3245e7bf25a61dff44
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Fri Jan 28 11:34:23 2022 +0000
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Fri Jan 28 20:18:06 2022 +0100

    use our own tempfile mechanism
    
    Change-Id: Ie7853ea8bd083d1056872cfad4323ff6cede235f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129097
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/hwpfilter/source/htags.cxx b/hwpfilter/source/htags.cxx
index b8cafcf38675..4644d286d75c 100644
--- a/hwpfilter/source/htags.cxx
+++ b/hwpfilter/source/htags.cxx
@@ -19,6 +19,9 @@
 
 #include "precompile.h"
 
+#include <o3tl/char16_t2wchar_t.hxx>
+#include <unotools/tempfile.hxx>
+
 #include <string.h>
 
 #include "hwplib.h"
@@ -108,27 +111,20 @@ void OlePicture::Read(HWPFile & hwpf)
           delete [] data;
           return;
     }
-    FILE *fp;
-    char tname[200];
-    wchar_t wtname[200];
-    tmpnam(tname);
-    if (nullptr == (fp = fopen(tname, "wb")))
-    {
-         delete [] data;
-         return;
-    }
-    fwrite(data, size, 1, fp);
+
+    utl::TempFile aTempFile;
+    aTempFile.EnableKillingFile();
+
+    SvFileStream aOutputStream(aTempFile.GetURL(), StreamMode::WRITE);
+    aOutputStream.WriteBytes(data, size);
     delete [] data;
-    fclose(fp);
-    MultiByteToWideChar(CP_ACP, 0, tname, -1, wtname, 200);
-    if( StgOpenStorage(wtname, nullptr,
+    aOutputStream.Close();
+    if( StgOpenStorage(o3tl::toW(aTempFile.GetFileName().getStr()), nullptr,
                     STGM_READWRITE|STGM_SHARE_EXCLUSIVE|STGM_TRANSACTED,
                     nullptr, 0, &pis) != S_OK ) {
          pis = nullptr;
-         unlink(tname);
          return;
     }
-    unlink(tname);
 #else
     hwpf.SkipBlock(size);
 #endif

Reply via email to