From cae861f0b32e01cb775214d783c98255acb60af0 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Wed, 17 Jul 2013 12:11:26 +0200 Subject: Fix memory leak with osl_getCurrentSecurity (). The result of osl_getCurrentSecurity () should always be deleted again with osl_freeSecurityHandle (). Change-Id: If0991937fcb24207d1f78166f61c4be22d423629 Reviewed-on: https://gerrit.libreoffice.org/4947 Reviewed-by: David Tardon Tested-by: David Tardon --- sal/osl/unx/file_url.cxx | 4 +++- sal/qa/osl/process/osl_process.cxx | 16 ++++++++++++---- sal/workben/t_osl_joinProcess.cxx | 16 ++++++++++++---- 3 files changed, 27 insertions(+), 9 deletions(-) (limited to 'sal') diff --git a/sal/osl/unx/file_url.cxx b/sal/osl/unx/file_url.cxx index 03de113eb335..304f8b4a5b93 100644 --- a/sal/osl/unx/file_url.cxx +++ b/sal/osl/unx/file_url.cxx @@ -259,7 +259,9 @@ oslFileError SAL_CALL osl_getSystemPathFromFileURL( rtl_uString *ustrFileURL, rt rtl_uString *pTmp2 = NULL; /* osl_getHomeDir returns file URL */ - osl_getHomeDir( osl_getCurrentSecurity(), &pTmp2 ); + oslSecurity pSecurity = osl_getCurrentSecurity(); + osl_getHomeDir( pSecurity , &pTmp2 ); + osl_freeSecurityHandle( pSecurity ); /* remove "file://" prefix */ rtl_uString_newFromStr_WithLength( &pTmp2, pTmp2->buffer + 7, pTmp2->length - 7 ); diff --git a/sal/qa/osl/process/osl_process.cxx b/sal/qa/osl/process/osl_process.cxx index f09567659552..5dcd55561884 100644 --- a/sal/qa/osl/process/osl_process.cxx +++ b/sal/qa/osl/process/osl_process.cxx @@ -138,16 +138,18 @@ public: void osl_joinProcessWithTimeout_timeout_failure() { oslProcess process; + oslSecurity security = osl_getCurrentSecurity(); oslProcessError osl_error = osl_executeProcess( suExecutableFileURL.pData, parameters_, parameters_count_, osl_Process_NORMAL, - osl_getCurrentSecurity(), + security, suCWD.pData, NULL, 0, &process); + osl_freeSecurityHandle(security); CPPUNIT_ASSERT_EQUAL_MESSAGE ( @@ -188,16 +190,18 @@ public: void osl_joinProcessWithTimeout_without_timeout_failure() { oslProcess process; + oslSecurity security = osl_getCurrentSecurity (); oslProcessError osl_error = osl_executeProcess( suExecutableFileURL.pData, parameters_, parameters_count_, osl_Process_NORMAL, - osl_getCurrentSecurity(), + security, suCWD.pData, NULL, 0, &process); + osl_freeSecurityHandle(security); CPPUNIT_ASSERT_EQUAL_MESSAGE ( @@ -228,16 +232,18 @@ public: void osl_joinProcessWithTimeout_infinite() { oslProcess process; + oslSecurity security = osl_getCurrentSecurity (); oslProcessError osl_error = osl_executeProcess( suExecutableFileURL.pData, parameters_, parameters_count_, osl_Process_NORMAL, - osl_getCurrentSecurity(), + security, suCWD.pData, NULL, 0, &process); + osl_freeSecurityHandle(security); CPPUNIT_ASSERT_EQUAL_MESSAGE ( @@ -264,16 +270,18 @@ public: void osl_joinProcess() { oslProcess process; + oslSecurity security = osl_getCurrentSecurity (); oslProcessError osl_error = osl_executeProcess( suExecutableFileURL.pData, parameters_, parameters_count_, osl_Process_NORMAL, - osl_getCurrentSecurity(), + security, suCWD.pData, NULL, 0, &process); + osl_freeSecurityHandle(security); CPPUNIT_ASSERT_EQUAL_MESSAGE ( diff --git a/sal/workben/t_osl_joinProcess.cxx b/sal/workben/t_osl_joinProcess.cxx index 8f3497d5b5ec..d043c5e343b3 100644 --- a/sal/workben/t_osl_joinProcess.cxx +++ b/sal/workben/t_osl_joinProcess.cxx @@ -46,16 +46,18 @@ public: void test_osl_joinProcessWithTimeout_timeout_failure() { oslProcess process; + oslSecurity security = osl_getCurrentSecurity(); oslProcessError osl_error = osl_executeProcess( IMAGE_NAME.pData, NULL, 0, osl_Process_NORMAL, - osl_getCurrentSecurity(), + security, CWD.pData, NULL, 0, &process); + osl_freeSecurityHandle(security); CPPUNIT_ASSERT_MESSAGE ( @@ -96,16 +98,18 @@ public: void test_osl_joinProcessWithTimeout_without_timeout_failure() { oslProcess process; + oslSecurity security = osl_getCurrentSecurity(); oslProcessError osl_error = osl_executeProcess( IMAGE_NAME.pData, NULL, 0, osl_Process_NORMAL, - osl_getCurrentSecurity(), + security, CWD.pData, NULL, 0, &process); + osl_freeSecurityHandle(security); CPPUNIT_ASSERT_MESSAGE ( @@ -136,16 +140,18 @@ public: void test_osl_joinProcessWithTimeout_infinite() { oslProcess process; + oslSecurity security = osl_getCurrentSecurity(); oslProcessError osl_error = osl_executeProcess( IMAGE_NAME.pData, NULL, 0, osl_Process_NORMAL, - osl_getCurrentSecurity(), + security, CWD.pData, NULL, 0, &process); + osl_freeSecurityHandle(security); CPPUNIT_ASSERT_MESSAGE ( @@ -172,16 +178,18 @@ public: void test_osl_joinProcess() { oslProcess process; + oslSecurity security = osl_getCurrentSecurity(); oslProcessError osl_error = osl_executeProcess( IMAGE_NAME.pData, NULL, 0, osl_Process_NORMAL, - osl_getCurrentSecurity(), + security, CWD.pData, NULL, 0, &process); + osl_freeSecurityHandle(security); CPPUNIT_ASSERT_MESSAGE ( -- cgit