From 668e68d3dfe7f187c51c5ff9af752a8d0369b426 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 2 Aug 2018 15:54:12 +0100 Subject: coverity#1438194 silence Resource leak MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I54cf8e4fc430feb2e34d3f6f0f2abce81973b09a Reviewed-on: https://gerrit.libreoffice.org/58481 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- sal/osl/unx/tempfile.cxx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'sal') diff --git a/sal/osl/unx/tempfile.cxx b/sal/osl/unx/tempfile.cxx index 2f9fb7182db6..1070dbe0eaa1 100644 --- a/sal/osl/unx/tempfile.cxx +++ b/sal/osl/unx/tempfile.cxx @@ -305,16 +305,18 @@ oslFileError SAL_CALL osl_createTempFile( osl_error = osl_removeFile(temp_file_url); if (osl_error == osl_File_E_None) + { *pHandle = temp_file_handle; - else - osl_closeFile(temp_file_handle); + temp_file_handle = nullptr; + } } else { if (pHandle) + { *pHandle = temp_file_handle; - else - osl_closeFile(temp_file_handle); + temp_file_handle = nullptr; + } rtl_uString_assign(ppustrTempFileURL, temp_file_url); } @@ -322,6 +324,9 @@ oslFileError SAL_CALL osl_createTempFile( rtl_uString_release(temp_file_url); } + if (temp_file_handle) + osl_closeFile(temp_file_handle); + rtl_uString_release(base_directory); return osl_error; -- cgit