Kaydet (Commit) cae861f0 authored tarafından Mark Wielaard's avatar Mark Wielaard Kaydeden (comit) David Tardon

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/4947Reviewed-by: 's avatarDavid Tardon <dtardon@redhat.com>
Tested-by: 's avatarDavid Tardon <dtardon@redhat.com>
üst 4cf02127
......@@ -149,6 +149,8 @@ static oslProcessError runProcessWithPathSearch(const OUString &rProgName,
rtl_uString* pArgs[], sal_uInt32 nArgs, oslProcess *pProcess,
oslFileHandle *pIn, oslFileHandle *pOut, oslFileHandle *pErr)
{
oslProcessError result;
oslSecurity pSecurity = osl_getCurrentSecurity();
#ifdef WNT
/*
* ooo#72096
......@@ -171,14 +173,17 @@ static oslProcessError runProcessWithPathSearch(const OUString &rProgName,
oslFileError err = osl_searchFileURL(rProgName.pData, path.pData, &url.pData);
if (err != osl_File_E_None)
return osl_Process_E_NotFound;
return osl_executeProcess_WithRedirectedIO(url.pData,
result = osl_executeProcess_WithRedirectedIO(url.pData,
pArgs, nArgs, osl_Process_HIDDEN,
osl_getCurrentSecurity(), 0, 0, 0, pProcess, pIn, pOut, pErr);
pSecurity, 0, 0, 0, pProcess, pIn, pOut, pErr);
#else
return osl_executeProcess_WithRedirectedIO(rProgName.pData,
result = osl_executeProcess_WithRedirectedIO(rProgName.pData,
pArgs, nArgs, osl_Process_SEARCHPATH | osl_Process_HIDDEN,
osl_getCurrentSecurity(), 0, 0, 0, pProcess, pIn, pOut, pErr);
pSecurity, 0, 0, 0, pProcess, pIn, pOut, pErr);
#endif
osl_freeSecurityHandle( pSecurity );
return result;
}
#if defined(WNT)
......
......@@ -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 );
......
......@@ -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
(
......
......@@ -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
(
......
......@@ -1083,14 +1083,16 @@ bool xpdf_ImportFromFile( const OUString& rURL,
oslFileHandle pIn = NULL;
oslFileHandle pOut = NULL;
oslFileHandle pErr = NULL;
oslSecurity pSecurity = osl_getCurrentSecurity ();
const oslProcessError eErr =
osl_executeProcess_WithRedirectedIO(converterURL.pData,
args,
nArgs,
osl_Process_SEARCHPATH|osl_Process_HIDDEN,
osl_getCurrentSecurity(),
pSecurity,
0, ppEnv, nEnv,
&aProcess, &pIn, &pOut, &pErr);
osl_freeSecurityHandle(pSecurity);
bool bRet=true;
try
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment