diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client.cpp | 19 | ||||
-rw-r--r-- | src/client.h | 4 | ||||
-rw-r--r-- | src/fbasicstring.h | 2 | ||||
-rw-r--r-- | 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 ) | |||
173 | sWriteBuf.append( (const char *)&nData, sizeof(nData) ); | 173 | sWriteBuf.append( (const char *)&nData, sizeof(nData) ); |
174 | } | 174 | } |
175 | 175 | ||
176 | void Bu::Client::read( void *pData, int nBytes ) | 176 | int Bu::Client::read( void *pData, int nBytes ) |
177 | { | 177 | { |
178 | if( nBytes > sReadBuf.getSize()-nRBOffset ) | ||
179 | { | ||
180 | nBytes = sReadBuf.getSize()-nRBOffset; | ||
181 | if( nBytes <= 0 ) | ||
182 | return 0; | ||
183 | } | ||
178 | memcpy( pData, sReadBuf.getStr()+nRBOffset, nBytes ); | 184 | memcpy( pData, sReadBuf.getStr()+nRBOffset, nBytes ); |
179 | nRBOffset += nBytes; | 185 | nRBOffset += nBytes; |
180 | if( sReadBuf.getSize()-nRBOffset == 0 ) | 186 | if( sReadBuf.getSize()-nRBOffset == 0 ) |
@@ -192,11 +198,20 @@ void Bu::Client::read( void *pData, int nBytes ) | |||
192 | sReadBuf.trimFront( nRBOffset ); | 198 | sReadBuf.trimFront( nRBOffset ); |
193 | nRBOffset = 0; | 199 | nRBOffset = 0; |
194 | } | 200 | } |
201 | |||
202 | return nBytes; | ||
195 | } | 203 | } |
196 | 204 | ||
197 | void Bu::Client::peek( void *pData, int nBytes, int nOffset ) | 205 | int Bu::Client::peek( void *pData, int nBytes, int nOffset ) |
198 | { | 206 | { |
207 | if( nBytes+nOffset > sReadBuf.getSize()-nRBOffset ) | ||
208 | { | ||
209 | nBytes = sReadBuf.getSize()-nRBOffset-nOffset; | ||
210 | if( nBytes <= 0 ) | ||
211 | return 0; | ||
212 | } | ||
199 | memcpy( pData, sReadBuf.getStr()+nRBOffset+nOffset, nBytes ); | 213 | memcpy( pData, sReadBuf.getStr()+nRBOffset+nOffset, nBytes ); |
214 | return nBytes; | ||
200 | } | 215 | } |
201 | 216 | ||
202 | void Bu::Client::seek( int nBytes ) | 217 | 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 | |||
43 | void write( uint16_t nData ); | 43 | void write( uint16_t nData ); |
44 | void write( uint32_t nData ); | 44 | void write( uint32_t nData ); |
45 | void write( uint64_t nData ); | 45 | void write( uint64_t nData ); |
46 | void read( void *pData, int nBytes ); | 46 | int read( void *pData, int nBytes ); |
47 | void peek( void *pData, int nBytes, int nOffset=0 ); | 47 | int peek( void *pData, int nBytes, int nOffset=0 ); |
48 | void seek( int nBytes ); | 48 | void seek( int nBytes ); |
49 | long getInputSize(); | 49 | long getInputSize(); |
50 | 50 | ||
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 | |||
1497 | return true; | 1497 | return true; |
1498 | if( core->nLength != pData.core->nLength ) | 1498 | if( core->nLength != pData.core->nLength ) |
1499 | return false; | 1499 | return false; |
1500 | if( pData.core->pFirst == NULL || core->pFirst == NULL ) | ||
1501 | return false; | ||
1500 | 1502 | ||
1501 | flatten(); | 1503 | flatten(); |
1502 | pData.flatten(); | 1504 | 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 @@ | |||
11 | 11 | ||
12 | Bu::Formatter::Formatter( Stream &rStream ) : | 12 | Bu::Formatter::Formatter( Stream &rStream ) : |
13 | rStream( rStream ), | 13 | rStream( rStream ), |
14 | bTempFmt( false ), | ||
14 | uIndent( 0 ), | 15 | uIndent( 0 ), |
15 | cIndent( '\t' ) | 16 | cIndent( '\t' ) |
16 | { | 17 | { |