summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Chaffraix <julien.chaffraix@gmail.com>2011-04-12 06:40:24 -0700
committerThorsten Behrens <tbehrens@novell.com>2011-04-14 12:27:54 +0200
commit3f490e80cfe654757f5b9001cee0236cd43d47ac (patch)
tree9dcf3dd1eb64fb7cb9d4c64eef3a3a695dcd9fe1
parentAdded handling for the write errors in receiveFdPipe. (diff)
downloadcore-3f490e80cfe654757f5b9001cee0236cd43d47ac.tar.gz
core-3f490e80cfe654757f5b9001cee0236cd43d47ac.zip
Fixed a potential null-dereferencing error in osl_closeProfile
Store the new profile in a temporary variable and assign it to the old profile after we have checked if it is null. Seen with CLang++.
-rw-r--r--sal/osl/unx/profile.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/sal/osl/unx/profile.c b/sal/osl/unx/profile.c
index c2a0cc490af9..8a76018635a1 100644
--- a/sal/osl/unx/profile.c
+++ b/sal/osl/unx/profile.c
@@ -274,6 +274,7 @@ static oslProfile SAL_CALL osl_psz_openProfile(const sal_Char *pszProfileName, o
sal_Bool SAL_CALL osl_closeProfile(oslProfile Profile)
{
osl_TProfileImpl* pProfile = (osl_TProfileImpl*)Profile;
+ osl_TProfileImpl* pTmpProfile;
#ifdef TRACE_OSL_PROFILE
OSL_TRACE("In osl_closeProfile\n");
@@ -303,22 +304,22 @@ sal_Bool SAL_CALL osl_closeProfile(oslProfile Profile)
if ( ! ( pProfile->m_Flags & osl_Profile_READLOCK ) && ( pProfile->m_Flags & FLG_MODIFIED ) )
{
- pProfile = acquireProfile(Profile,sal_True);
+ pTmpProfile = acquireProfile(Profile,sal_True);
- if ( pProfile != 0 )
+ if ( pTmpProfile != 0 )
{
- sal_Bool bRet = storeProfile(pProfile, sal_True);
+ sal_Bool bRet = storeProfile(pTmpProfile, sal_True);
OSL_ASSERT(bRet);
(void)bRet;
}
}
else
{
- pProfile = acquireProfile(Profile,sal_False);
+ pTmpProfile = acquireProfile(Profile,sal_False);
}
- if ( pProfile == 0 )
+ if ( pTmpProfile == 0 )
{
pthread_mutex_unlock(&(pProfile->m_AccessLock));
#ifdef TRACE_OSL_PROFILE
@@ -327,6 +328,8 @@ sal_Bool SAL_CALL osl_closeProfile(oslProfile Profile)
return sal_False;
}
+ pProfile = pTmpProfile;
+
if (pProfile->m_pFile != NULL)
closeFileImpl(pProfile->m_pFile,pProfile->m_Flags);