summaryrefslogtreecommitdiff
path: root/extensions/source
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2020-05-25 09:54:39 +0200
committerStephan Bergmann <sbergman@redhat.com>2020-05-27 16:07:44 +0200
commit48f61a745554a62853e94e9f0559ecbf131baca2 (patch)
tree42ad1480c16aa9104a4048038a90cea8576d5187 /extensions/source
parentf50a0dc7d66d27a6dbd17091b1652ba603cd6726 (diff)
Revert "Revert 'Fix leak in extensions/updatecheck'"
This reverts commit f7a77ec55a94bcac13cde7c7e7644d70771b6098. Reason for revert: The original 05ab836cf3001093a6e375bcb3e4654bbedcfa52 "Fix leak in extensions/updatecheck" had not been wrong per se. The comment at <https://gerrit.libreoffice.org/c/core/+/94658/7# message-4afcb072d281450932788a9e8ea88cf2c6798e29> said "It shouldn't matter in practice". So the issue that comment raised can easily be either ignored completely or addressed in a follow-up commit. Change-Id: I75afaba57e3a6ba4fcce526481ff0df94360d929 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94681 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'extensions/source')
-rw-r--r--extensions/source/update/check/updatecheck.cxx10
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