aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2007-06-11 21:58:10 +0000
committerMike Buland <eichlan@xagasoft.com>2007-06-11 21:58:10 +0000
commitb6f50f249ba3b18c597531a2d5dbc45f7bfa3eaa (patch)
treecbba1919fd532d91559b6361ed604806f467e380 /src
parent7ba47b5b688afd7e04b38a3e0e4aa018c10a9a59 (diff)
downloadlibbu++-b6f50f249ba3b18c597531a2d5dbc45f7bfa3eaa.tar.gz
libbu++-b6f50f249ba3b18c597531a2d5dbc45f7bfa3eaa.tar.bz2
libbu++-b6f50f249ba3b18c597531a2d5dbc45f7bfa3eaa.tar.xz
libbu++-b6f50f249ba3b18c597531a2d5dbc45f7bfa3eaa.zip
Another few fixes for zero-length strings in fstring.
Diffstat (limited to '')
-rw-r--r--src/fstring.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/fstring.h b/src/fstring.h
index 7dda87c..93a0042 100644
--- a/src/fstring.h
+++ b/src/fstring.h
@@ -117,6 +117,8 @@ namespace Bu
117 { 117 {
118 long nLen; 118 long nLen;
119 for( nLen = 0; pData[nLen] != (chr)0; nLen++ ); 119 for( nLen = 0; pData[nLen] != (chr)0; nLen++ );
120 if( nLen == 0 )
121 return;
120 122
121 Chunk *pNew = newChunk( nLen ); 123 Chunk *pNew = newChunk( nLen );
122 cpy( pNew->pData, pData, nLen ); 124 cpy( pNew->pData, pData, nLen );
@@ -126,6 +128,9 @@ namespace Bu
126 128
127 void append( const chr *pData, long nLen ) 129 void append( const chr *pData, long nLen )
128 { 130 {
131 if( nLen == 0 )
132 return;
133
129 Chunk *pNew = newChunk( nLen ); 134 Chunk *pNew = newChunk( nLen );
130 135
131 cpy( pNew->pData, pData, nLen ); 136 cpy( pNew->pData, pData, nLen );
@@ -235,6 +240,8 @@ namespace Bu
235 240
236 MyType &operator +=( const MyType &rSrc ) 241 MyType &operator +=( const MyType &rSrc )
237 { 242 {
243 if( rSrc.nLength == 0 )
244 return (*this);
238 rSrc.flatten(); 245 rSrc.flatten();
239 append( rSrc.pFirst->pData, rSrc.nLength ); 246 append( rSrc.pFirst->pData, rSrc.nLength );
240 247
@@ -612,6 +619,8 @@ namespace Bu
612 { 619 {
613 if( isShared() == false ) 620 if( isShared() == false )
614 return; 621 return;
622 if( pFirst == NULL )
623 return;
615 624
616 Chunk *pNew = newChunk( nLength ); 625 Chunk *pNew = newChunk( nLength );
617 chr *pos = pNew->pData; 626 chr *pos = pNew->pData;