diff options
author | Michael Stahl <mstahl@redhat.com> | 2015-02-05 22:07:28 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2015-02-05 23:33:07 +0100 |
commit | b0ef5cf258f3a84054c052f0a09a208dbc17fdf3 (patch) | |
tree | 3e5d524d9acf1fce1a67862497ccbeb5492e9703 /sal/rtl/ustrbuf.cxx | |
parent | 30f6ec7cfdf63cea265148bbe3a07d8df34e96d5 (diff) |
sal: add some argument checking assertions for strings and buffers
Also remove some now redundant asserts from headers.
Some of these actually trigger on unit tests so are commented out.
Change-Id: I07c6b2b2bd175361691a141f22eec584e3ab8f0b
Diffstat (limited to 'sal/rtl/ustrbuf.cxx')
-rw-r--r-- | sal/rtl/ustrbuf.cxx | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/sal/rtl/ustrbuf.cxx b/sal/rtl/ustrbuf.cxx index 2ebae71dbaf0..2755ca6f2899 100644 --- a/sal/rtl/ustrbuf.cxx +++ b/sal/rtl/ustrbuf.cxx @@ -33,6 +33,8 @@ void SAL_CALL rtl_uStringbuffer_newFromStr_WithLength( rtl_uString ** newStr, const sal_Unicode * value, sal_Int32 count) { + assert(newStr); + assert(count >= 0); if (!value) { rtl_uString_new_WithLength( newStr, 16 ); @@ -56,6 +58,8 @@ rtl_uString * SAL_CALL rtl_uStringBuffer_refReturn( rtl_uString * pThis ) rtl_uString * SAL_CALL rtl_uStringBuffer_makeStringAndClear( rtl_uString ** ppThis, sal_Int32 *nCapacity ) { + assert(ppThis); + assert(nCapacity); // avoid an un-necessary atomic ref/unref pair rtl_uString *pStr = *ppThis; *ppThis = NULL; @@ -72,6 +76,9 @@ sal_Int32 SAL_CALL rtl_uStringbuffer_newFromStringBuffer( rtl_uString ** newStr, sal_Int32 capacity, rtl_uString * oldStr ) { + assert(newStr); + assert(capacity >= 0); + assert(oldStr); sal_Int32 newCapacity = capacity; if (newCapacity < oldStr->length) @@ -90,6 +97,9 @@ sal_Int32 SAL_CALL rtl_uStringbuffer_newFromStringBuffer( rtl_uString ** newStr, void SAL_CALL rtl_uStringbuffer_ensureCapacity (rtl_uString ** This, sal_Int32* capacity, sal_Int32 minimumCapacity) { + assert(This); + assert(capacity && *capacity >= 0); + assert(minimumCapacity >= 0); if (minimumCapacity > *capacity) { rtl_uString * pTmp = *This; @@ -116,6 +126,11 @@ void SAL_CALL rtl_uStringbuffer_insert( rtl_uString ** This, const sal_Unicode * str, sal_Int32 len) { + assert(This); + assert(capacity && *capacity >= 0); + assert(offset >= 0 && offset <= (**This).length); + assert(len == 0 || str != nullptr); + assert(len >= 0); sal_Int32 nOldLen; sal_Unicode * pBuf; sal_Int32 n; @@ -174,6 +189,11 @@ void SAL_CALL rtl_uStringbuffer_insert_ascii( /*inout*/rtl_uString ** This, const sal_Char * str, sal_Int32 len) { + assert(This); + assert(capacity && *capacity >= 0); + assert(offset >= 0 && offset <= (**This).length); + assert(len == 0 || str != nullptr); + assert(len >= 0); sal_Int32 nOldLen; sal_Unicode * pBuf; sal_Int32 n; @@ -214,6 +234,9 @@ void SAL_CALL rtl_uStringbuffer_remove( rtl_uString ** This, sal_Int32 start, sal_Int32 len ) { + assert(This); + assert(start >= 0 && start <= (**This).length); + assert(len >= 0); sal_Int32 nTailLen; sal_Unicode * pBuf; |