diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-10-02 21:06:37 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-10-03 09:07:57 +0100 |
commit | adf74f8287a626d5dbd40a65c87cc79702b482fb (patch) | |
tree | 9fd7d78dc71a25f903239265abb58949c32081ac | |
parent | 898cb8b726128c98e44539ca3c24e72ceb1742c6 (diff) |
coverity#1241327 Dereference after null check
Change-Id: I214884e9ee1d49dcc4db71f8744513468b912691
-rw-r--r-- | sal/rtl/strtmpl.cxx | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/sal/rtl/strtmpl.cxx b/sal/rtl/strtmpl.cxx index a990159331b2..71a2fb2a1e9e 100644 --- a/sal/rtl/strtmpl.cxx +++ b/sal/rtl/strtmpl.cxx @@ -1375,24 +1375,22 @@ void SAL_CALL IMPL_RTL_STRINGNAME( newFromLiteral )( IMPL_RTL_STRINGDATA** ppThi *ppThis = IMPL_RTL_STRINGNAME( ImplAlloc )( nLen + allocExtra ); assert( *ppThis != NULL ); - if ( (*ppThis) ) + + (*ppThis)->length = nLen; // fix after possible allocExtra != 0 + (*ppThis)->buffer[nLen] = 0; + IMPL_RTL_STRCODE* pBuffer = (*ppThis)->buffer; + sal_Int32 nCount; + for( nCount = nLen; nCount > 0; --nCount ) { - (*ppThis)->length = nLen; // fix after possible allocExtra != 0 - (*ppThis)->buffer[nLen] = 0; - IMPL_RTL_STRCODE* pBuffer = (*ppThis)->buffer; - sal_Int32 nCount; - for( nCount = nLen; nCount > 0; --nCount ) - { - /* Check ASCII range */ - SAL_WARN_IF( ((unsigned char)*pCharStr) > 127, "rtl.string", - "rtl_uString_newFromLiteral - Found char > 127" ); - SAL_WARN_IF( ((unsigned char)*pCharStr) == '\0', "rtl.string", - "rtl_uString_newFromLiteral - Found embedded \\0 character" ); - - *pBuffer = *pCharStr; - pBuffer++; - pCharStr++; - } + /* Check ASCII range */ + SAL_WARN_IF( ((unsigned char)*pCharStr) > 127, "rtl.string", + "rtl_uString_newFromLiteral - Found char > 127" ); + SAL_WARN_IF( ((unsigned char)*pCharStr) == '\0', "rtl.string", + "rtl_uString_newFromLiteral - Found embedded \\0 character" ); + + *pBuffer = *pCharStr; + pBuffer++; + pCharStr++; } RTL_LOG_STRING_NEW( *ppThis ); |