diff options
author | Rüdiger Timm <rt@openoffice.org> | 2004-03-30 15:31:51 +0000 |
---|---|---|
committer | Rüdiger Timm <rt@openoffice.org> | 2004-03-30 15:31:51 +0000 |
commit | 4ba327f4e090a17e50ba099b42575a907d00b8f8 (patch) | |
tree | bbfb263d233aefa600f0a1b77c9f2304d0dd90f6 /sal/rtl | |
parent | aa40abec8a3fa321e6194099e9a5bedd7195be30 (diff) |
INTEGRATION: CWS sb14 (1.17.68); FILE MERGED
2004/03/11 14:41:36 sb 1.17.68.1: #i21150# rtl_string2UString and OUString::OUString(sal_Char const *, sal_Int32, rtl_TextEncoding, sal_uInt32) handle out-of-memory conditions.
Diffstat (limited to 'sal/rtl')
-rw-r--r-- | sal/rtl/source/ustring.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/sal/rtl/source/ustring.c b/sal/rtl/source/ustring.c index 546d7664d04d..3525bea2edfa 100644 --- a/sal/rtl/source/ustring.c +++ b/sal/rtl/source/ustring.c @@ -2,9 +2,9 @@ * * $RCSfile: ustring.c,v $ * - * $Revision: 1.17 $ + * $Revision: 1.18 $ * - * last change: $Author: hr $ $Date: 2003-08-07 14:58:22 $ + * last change: $Author: rt $ $Date: 2004-03-30 16:31:51 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -399,6 +399,7 @@ void SAL_CALL rtl_uString_newFromAscii( rtl_uString** ppThis, IMPL_RTL_STRINGNAME( release )( *ppThis ); *ppThis = IMPL_RTL_STRINGNAME( ImplAlloc )( nLen ); + OSL_ASSERT(*ppThis != NULL); if ( (*ppThis) ) { IMPL_RTL_STRCODE* pBuffer = (*ppThis)->buffer; @@ -474,6 +475,9 @@ void SAL_CALL rtl_string2UString( rtl_uString** ppThis, { IMPL_RTL_STRCODE* pBuffer; *ppThis = IMPL_RTL_STRINGNAME( ImplAlloc )( nLen ); + if (*ppThis == NULL) { + return; + } pBuffer = (*ppThis)->buffer; do { @@ -509,6 +513,9 @@ void SAL_CALL rtl_string2UString( rtl_uString** ppThis, { IMPL_RTL_STRCODE* pBuffer; *ppThis = IMPL_RTL_STRINGNAME( ImplAlloc )( nLen ); + if (*ppThis == NULL) { + return; + } pBuffer = (*ppThis)->buffer; do { @@ -532,6 +539,9 @@ void SAL_CALL rtl_string2UString( rtl_uString** ppThis, hConverter = rtl_createTextToUnicodeConverter( eTextEncoding ); pTemp = IMPL_RTL_STRINGNAME( ImplAlloc )( nNewLen ); + if (pTemp == NULL) { + return; + } nDestChars = rtl_convertTextToUnicode( hConverter, 0, pStr, nLen, pTemp->buffer, nNewLen, @@ -547,6 +557,9 @@ void SAL_CALL rtl_string2UString( rtl_uString** ppThis, rtl_freeMemory( pTemp ); nNewLen += 8; pTemp = IMPL_RTL_STRINGNAME( ImplAlloc )( nNewLen ); + if (pTemp == NULL) { + return; + } nDestChars = rtl_convertTextToUnicode( hConverter, 0, pStr, nLen, pTemp->buffer, nNewLen, @@ -559,9 +572,11 @@ void SAL_CALL rtl_string2UString( rtl_uString** ppThis, if ( nNewLen > nDestChars+8 ) { rtl_uString* pTemp2 = IMPL_RTL_STRINGNAME( ImplAlloc )( nDestChars ); - rtl_str_ImplCopy( pTemp2->buffer, pTemp->buffer, nDestChars ); - rtl_freeMemory( pTemp ); - pTemp = pTemp2; + if (pTemp2 != NULL) { + rtl_str_ImplCopy(pTemp2->buffer, pTemp->buffer, nDestChars); + rtl_freeMemory(pTemp); + pTemp = pTemp2; + } } else { |