summaryrefslogtreecommitdiffstats
path: root/sal/rtl/strbuf.cxx
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-02-05 22:07:28 +0100
committerMichael Stahl <mstahl@redhat.com>2015-02-05 23:33:07 +0100
commitb0ef5cf258f3a84054c052f0a09a208dbc17fdf3 (patch)
tree3e5d524d9acf1fce1a67862497ccbeb5492e9703 /sal/rtl/strbuf.cxx
parentResolves tdf#89129: crash when defining a specific relationship (diff)
downloadcore-b0ef5cf258f3a84054c052f0a09a208dbc17fdf3.tar.gz
core-b0ef5cf258f3a84054c052f0a09a208dbc17fdf3.zip
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/strbuf.cxx')
-rw-r--r--sal/rtl/strbuf.cxx16
1 files changed, 16 insertions, 0 deletions
diff --git a/sal/rtl/strbuf.cxx b/sal/rtl/strbuf.cxx
index f75d0cc7ef57..bb42dee4a0d4 100644
--- a/sal/rtl/strbuf.cxx
+++ b/sal/rtl/strbuf.cxx
@@ -29,6 +29,8 @@ void SAL_CALL rtl_stringbuffer_newFromStr_WithLength( rtl_String ** newStr,
const sal_Char * value,
sal_Int32 count )
{
+ assert(newStr);
+ assert(count >= 0);
if (!value)
{
rtl_string_new_WithLength( newStr, 16 );
@@ -48,6 +50,9 @@ sal_Int32 SAL_CALL rtl_stringbuffer_newFromStringBuffer( rtl_String ** newStr,
sal_Int32 capacity,
rtl_String * oldStr )
{
+ assert(newStr);
+ assert(oldStr);
+ assert(capacity >= 0);
sal_Int32 newCapacity = capacity;
if (newCapacity < oldStr->length)
@@ -67,6 +72,9 @@ sal_Int32 SAL_CALL rtl_stringbuffer_newFromStringBuffer( rtl_String ** newStr,
void SAL_CALL rtl_stringbuffer_ensureCapacity
(rtl_String ** This, sal_Int32* capacity, sal_Int32 minimumCapacity)
{
+ assert(This);
+// assert(capacity && *capacity >= 0);
+// assert(minimumCapacity >= 0);
if (minimumCapacity > *capacity)
{
rtl_String * pTmp = *This;
@@ -94,6 +102,11 @@ void SAL_CALL rtl_stringbuffer_insert( rtl_String ** 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_Char * pBuf;
sal_Int32 n;
@@ -134,6 +147,9 @@ void SAL_CALL rtl_stringbuffer_remove( rtl_String ** This,
sal_Int32 start,
sal_Int32 len )
{
+ assert(This);
+ assert(start >= 0 && start <= (**This).length);
+ assert(len >= 0);
sal_Int32 nTailLen;
sal_Char * pBuf;