diff options
author | Julien Chaffraix <julien.chaffraix@gmail.com> | 2011-04-12 06:40:24 -0700 |
---|---|---|
committer | Thorsten Behrens <tbehrens@novell.com> | 2011-04-14 12:27:54 +0200 |
commit | e437226fc306041dba92b8d28c604e7f4262928d (patch) | |
tree | 9ccb10fd8c13ba277898ffb38ad7eefeb086cad5 | |
parent | 7d0d1f658a970574c663c46459cd2520a8696e37 (diff) |
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.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/sal/osl/unx/profile.c b/sal/osl/unx/profile.c index 7c7b04cc4..c56c8bbaa 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); |