diff options
author | Michael Meeks <michael.meeks@suse.com> | 2012-12-18 17:43:56 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2012-12-18 17:44:54 +0000 |
commit | 09123760860f99756d37b70557d83f707fda6b17 (patch) | |
tree | bed00d794113197709936cc9e07d4049d36c17e7 /sal | |
parent | 058702256211804a449ae7e16b4fc4bd16236f40 (diff) |
fdo#58473 - fix transliteration crasher caused by writing const string.
Diffstat (limited to 'sal')
-rw-r--r-- | sal/inc/rtl/string.h | 2 | ||||
-rw-r--r-- | sal/inc/rtl/ustring.h | 5 | ||||
-rw-r--r-- | sal/rtl/source/strtmpl.cxx | 4 |
3 files changed, 7 insertions, 4 deletions
diff --git a/sal/inc/rtl/string.h b/sal/inc/rtl/string.h index bfeecf781e62..26fa5c728666 100644 --- a/sal/inc/rtl/string.h +++ b/sal/inc/rtl/string.h @@ -821,6 +821,8 @@ SAL_DLLPUBLIC void SAL_CALL rtl_string_new( rtl_String ** newStr ) SAL_THROW_EXT The reference count of the new string will be 1. The length of the string will be nLen. This function does not handle out-of-memory conditions. + For nLen < 0 or failed allocation this method returns NULL. + The characters of the capacity are not cleared, and the length is set to nLen, unlike the similar method of rtl_String_new_WithLength which zeros out the buffer, and sets the length to 0. So should be somewhat diff --git a/sal/inc/rtl/ustring.h b/sal/inc/rtl/ustring.h index fe2f2f47607d..1ff75bdeb319 100644 --- a/sal/inc/rtl/ustring.h +++ b/sal/inc/rtl/ustring.h @@ -1152,8 +1152,9 @@ SAL_DLLPUBLIC void SAL_CALL rtl_uString_new( /** Allocate a new string containing space for a given number of characters. The reference count of the new string will be 1. The length of the string - will be nLen. This function throws std::bad_alloc on out-of-memory - conditions. + will be nLen. This function does not handle out-of-memory conditions. + + For nLen < 0 or failed allocation this method returns NULL. The characters of the capacity are not cleared, and the length is set to nLen, unlike the similar method of rtl_uString_new_WithLength which diff --git a/sal/rtl/source/strtmpl.cxx b/sal/rtl/source/strtmpl.cxx index f715a581e2ce..cdb4f11a0254 100644 --- a/sal/rtl/source/strtmpl.cxx +++ b/sal/rtl/source/strtmpl.cxx @@ -1069,8 +1069,8 @@ void SAL_CALL IMPL_RTL_STRINGNAME( new )( IMPL_RTL_STRINGDATA** ppThis ) IMPL_RTL_STRINGDATA* SAL_CALL IMPL_RTL_STRINGNAME( alloc )( sal_Int32 nLen ) SAL_THROW_EXTERN_C() { - if ( nLen <= 0 ) - return (IMPL_RTL_STRINGDATA*) (&IMPL_RTL_EMPTYSTRING); + if ( nLen < 0 ) + return NULL; else return IMPL_RTL_STRINGNAME( ImplAlloc )( nLen ); } |