diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2020-05-22 10:03:15 +0200 |
---|---|---|
committer | Julien Nabet <serval2412@yahoo.fr> | 2020-05-23 09:11:34 +0200 |
commit | 05ab836cf3001093a6e375bcb3e4654bbedcfa52 (patch) | |
tree | c22a12d1afb29e4888ab386515f66350f07f30af /extensions | |
parent | 9c621ee8ea41a1c53bfeca49827290826785973e (diff) |
Fix leak in extensions/updatecheck
Change-Id: I693d32c6f1136dbe500b5390954fc77444144dbd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94658
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/source/update/check/updatecheck.cxx | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/extensions/source/update/check/updatecheck.cxx b/extensions/source/update/check/updatecheck.cxx index a4e18c193046..217c05986129 100644 --- a/extensions/source/update/check/updatecheck.cxx +++ b/extensions/source/update/check/updatecheck.cxx @@ -17,6 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <comphelper/scopeguard.hxx> #include <config_folders.h> #include "updatecheck.hxx" @@ -136,6 +137,12 @@ OUString getImageFromFileName(const OUString& aFile) nullptr, &hOut, nullptr // [out] File handles for redirected I/O ); + // Create a guard to ensure correct cleanup in its dtor in any case + comphelper::ScopeGuard g([hOut, hProcess] () { + osl_closeFile(hOut); + osl_freeProcessHandle(hProcess); + }); + if( osl_Process_E_None == rc ) { oslProcessInfo aInfo; @@ -169,9 +176,6 @@ OUString getImageFromFileName(const OUString& aFile) return aImageName; } } - - osl_closeFile(hOut); - osl_freeProcessHandle(hProcess); } } #endif |