diff options
author | Michael Meeks <michael.meeks@suse.com> | 2012-10-02 18:39:30 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2012-10-02 18:39:54 +0100 |
commit | 595ba03fd4769c069bbe0431ab878956ef1c37ad (patch) | |
tree | a0db9fe4e82e34b8606bc5be54d24df49a749e9a /sal/rtl | |
parent | 2d25eea6949196d2275d8b2bd484e6dab0163a33 (diff) |
update string copy semantics to be undefined in a non-crashing way.
Change-Id: I03bb4db5931932280e368012cbaee6bef2854dd6
Diffstat (limited to 'sal/rtl')
-rw-r--r-- | sal/rtl/source/strtmpl.cxx | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/sal/rtl/source/strtmpl.cxx b/sal/rtl/source/strtmpl.cxx index ebb0da199f2c..6069349bd36a 100644 --- a/sal/rtl/source/strtmpl.cxx +++ b/sal/rtl/source/strtmpl.cxx @@ -1194,6 +1194,29 @@ void SAL_CALL IMPL_RTL_STRINGNAME( newFromStr_WithLength )( IMPL_RTL_STRINGDATA* /* ----------------------------------------------------------------------- */ +void SAL_CALL IMPL_RTL_STRINGNAME( newFromSubString )( IMPL_RTL_STRINGDATA** ppThis, + const IMPL_RTL_STRINGDATA* pFrom, + sal_Int32 beginIndex, + sal_Int32 count ) + SAL_THROW_EXTERN_C() +{ + if ( beginIndex == 0 && count == pFrom->length ) + { + IMPL_RTL_STRINGNAME( assign )( ppThis, const_cast< IMPL_RTL_STRINGDATA * >( pFrom ) ); + return; + } + if ( count < 0 || beginIndex < 0 || beginIndex + count > pFrom->length ) + { + OSL_FAIL( "Out of bounds substring access" ); + IMPL_RTL_STRINGNAME( newFromLiteral )( ppThis, "!!br0ken!!", 10, 0 ); + return; + } + + IMPL_RTL_STRINGNAME( newFromStr_WithLength )( ppThis, pFrom->buffer + beginIndex, count ); +} + +/* ----------------------------------------------------------------------- */ + // Used when creating from string literals. void SAL_CALL IMPL_RTL_STRINGNAME( newFromLiteral )( IMPL_RTL_STRINGDATA** ppThis, const sal_Char* pCharStr, |