From fdf7e508f70bbf24adeb1beba2fc5ab825217f92 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Sun, 2 May 2010 01:24:55 +0000 Subject: wow, bug fixes everywhere. --- src/client.cpp | 19 +++++++++++++++++-- src/client.h | 4 ++-- src/fbasicstring.h | 2 ++ src/formatter.cpp | 1 + 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/client.cpp b/src/client.cpp index 2ea72a2..95008f9 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -173,8 +173,14 @@ void Bu::Client::write( uint64_t nData ) sWriteBuf.append( (const char *)&nData, sizeof(nData) ); } -void Bu::Client::read( void *pData, int nBytes ) +int Bu::Client::read( void *pData, int nBytes ) { + if( nBytes > sReadBuf.getSize()-nRBOffset ) + { + nBytes = sReadBuf.getSize()-nRBOffset; + if( nBytes <= 0 ) + return 0; + } memcpy( pData, sReadBuf.getStr()+nRBOffset, nBytes ); nRBOffset += nBytes; if( sReadBuf.getSize()-nRBOffset == 0 ) @@ -192,11 +198,20 @@ void Bu::Client::read( void *pData, int nBytes ) sReadBuf.trimFront( nRBOffset ); nRBOffset = 0; } + + return nBytes; } -void Bu::Client::peek( void *pData, int nBytes, int nOffset ) +int Bu::Client::peek( void *pData, int nBytes, int nOffset ) { + if( nBytes+nOffset > sReadBuf.getSize()-nRBOffset ) + { + nBytes = sReadBuf.getSize()-nRBOffset-nOffset; + if( nBytes <= 0 ) + return 0; + } memcpy( pData, sReadBuf.getStr()+nRBOffset+nOffset, nBytes ); + return nBytes; } void Bu::Client::seek( int nBytes ) diff --git a/src/client.h b/src/client.h index 28db088..aecb16c 100644 --- a/src/client.h +++ b/src/client.h @@ -43,8 +43,8 @@ namespace Bu void write( uint16_t nData ); void write( uint32_t nData ); void write( uint64_t nData ); - void read( void *pData, int nBytes ); - void peek( void *pData, int nBytes, int nOffset=0 ); + int read( void *pData, int nBytes ); + int peek( void *pData, int nBytes, int nOffset=0 ); void seek( int nBytes ); long getInputSize(); diff --git a/src/fbasicstring.h b/src/fbasicstring.h index e965de8..73951a6 100644 --- a/src/fbasicstring.h +++ b/src/fbasicstring.h @@ -1497,6 +1497,8 @@ namespace Bu return true; if( core->nLength != pData.core->nLength ) return false; + if( pData.core->pFirst == NULL || core->pFirst == NULL ) + return false; flatten(); pData.flatten(); diff --git a/src/formatter.cpp b/src/formatter.cpp index 3e0f41e..ce92caa 100644 --- a/src/formatter.cpp +++ b/src/formatter.cpp @@ -11,6 +11,7 @@ Bu::Formatter::Formatter( Stream &rStream ) : rStream( rStream ), + bTempFmt( false ), uIndent( 0 ), cIndent( '\t' ) { -- cgit v1.2.3