diff options
| author | Mike Buland <eichlan@xagasoft.com> | 2007-08-14 14:37:22 +0000 |
|---|---|---|
| committer | Mike Buland <eichlan@xagasoft.com> | 2007-08-14 14:37:22 +0000 |
| commit | f1d6b50ac5a014a5cd87a605bd4f4e1e6342ef7d (patch) | |
| tree | ba8615da5a64ea173001156a74fb1903ed6da9c6 /src/fstring.h | |
| parent | cd0fef04fab0229ac9bb332806342fd8ee3c8673 (diff) | |
| download | libbu++-f1d6b50ac5a014a5cd87a605bd4f4e1e6342ef7d.tar.gz libbu++-f1d6b50ac5a014a5cd87a605bd4f4e1e6342ef7d.tar.bz2 libbu++-f1d6b50ac5a014a5cd87a605bd4f4e1e6342ef7d.tar.xz libbu++-f1d6b50ac5a014a5cd87a605bd4f4e1e6342ef7d.zip | |
Fixed a crash in the FString::prepend function on a null string corner case.
Also added more tests to the FString unit tests and switched the ParamProc to
using FString instead of std::string, this will break a few programs in very
minor ways, a few seconds each to fix, I'd say.
Diffstat (limited to 'src/fstring.h')
| -rw-r--r-- | src/fstring.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/fstring.h b/src/fstring.h index 3cf42ef..63e1e1a 100644 --- a/src/fstring.h +++ b/src/fstring.h | |||
| @@ -183,6 +183,8 @@ namespace Bu | |||
| 183 | */ | 183 | */ |
| 184 | void prepend( const chr *pData ) | 184 | void prepend( const chr *pData ) |
| 185 | { | 185 | { |
| 186 | if( pData == NULL ) | ||
| 187 | return; | ||
| 186 | long nLen; | 188 | long nLen; |
| 187 | for( nLen = 0; pData[nLen] != (chr)0; nLen++ ); | 189 | for( nLen = 0; pData[nLen] != (chr)0; nLen++ ); |
| 188 | 190 | ||
| @@ -261,6 +263,7 @@ namespace Bu | |||
| 261 | return NULL; | 263 | return NULL; |
| 262 | 264 | ||
| 263 | flatten(); | 265 | flatten(); |
| 266 | pFirst->pData[nLength] = (chr)0; | ||
| 264 | return pFirst->pData; | 267 | return pFirst->pData; |
| 265 | } | 268 | } |
| 266 | 269 | ||
| @@ -274,6 +277,7 @@ namespace Bu | |||
| 274 | return NULL; | 277 | return NULL; |
| 275 | 278 | ||
| 276 | flatten(); | 279 | flatten(); |
| 280 | pFirst->pData[nLength] = (chr)0; | ||
| 277 | return pFirst->pData; | 281 | return pFirst->pData; |
| 278 | } | 282 | } |
| 279 | 283 | ||
| @@ -287,6 +291,7 @@ namespace Bu | |||
| 287 | return NULL; | 291 | return NULL; |
| 288 | 292 | ||
| 289 | flatten(); | 293 | flatten(); |
| 294 | pFirst->pData[nLength] = (chr)0; | ||
| 290 | return pFirst->pData; | 295 | return pFirst->pData; |
| 291 | } | 296 | } |
| 292 | 297 | ||
| @@ -300,6 +305,7 @@ namespace Bu | |||
| 300 | return NULL; | 305 | return NULL; |
| 301 | 306 | ||
| 302 | flatten(); | 307 | flatten(); |
| 308 | pFirst->pData[nLength] = (chr)0; | ||
| 303 | return pFirst->pData; | 309 | return pFirst->pData; |
| 304 | } | 310 | } |
| 305 | 311 | ||
| @@ -416,6 +422,7 @@ namespace Bu | |||
| 416 | } | 422 | } |
| 417 | 423 | ||
| 418 | flatten(); | 424 | flatten(); |
| 425 | pFirst->pData[nLength] = (chr)0; | ||
| 419 | const chr *a = pData; | 426 | const chr *a = pData; |
| 420 | chr *b = pFirst->pData; | 427 | chr *b = pFirst->pData; |
| 421 | for( long j = 0; *a!=(chr)0 || *b!=(chr)0; j++, a++, b++ ) | 428 | for( long j = 0; *a!=(chr)0 || *b!=(chr)0; j++, a++, b++ ) |
