diff options
author | Mike Buland <eichlan@xagasoft.com> | 2008-12-29 21:46:03 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2008-12-29 21:46:03 +0000 |
commit | 1743bd0eacec94c6f6e3c89e16d0bd6d301017e8 (patch) | |
tree | a4de5c4bf9ebb8b9181daa8ec52c697dc3e1ff63 /src/tafreader.cpp | |
parent | f461b3c1839e5cfc85685ed1cb828ecaa74d6912 (diff) | |
download | libbu++-1743bd0eacec94c6f6e3c89e16d0bd6d301017e8.tar.gz libbu++-1743bd0eacec94c6f6e3c89e16d0bd6d301017e8.tar.bz2 libbu++-1743bd0eacec94c6f6e3c89e16d0bd6d301017e8.tar.xz libbu++-1743bd0eacec94c6f6e3c89e16d0bd6d301017e8.zip |
Corrected the premature end of stream read corner case in Taf...it was freaking
out and allocating all memory, now it just throws an exception.
Diffstat (limited to 'src/tafreader.cpp')
-rw-r--r-- | src/tafreader.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/tafreader.cpp b/src/tafreader.cpp index 7bb0933..4408cce 100644 --- a/src/tafreader.cpp +++ b/src/tafreader.cpp | |||
@@ -209,15 +209,32 @@ void Bu::TafReader::next() | |||
209 | iCol++; | 209 | iCol++; |
210 | if( c == '}' ) | 210 | if( c == '}' ) |
211 | { | 211 | { |
212 | sIn.read( &c, 1 ); | 212 | rawread( &c ); |
213 | if( c != '}' ) | 213 | if( c != '}' ) |
214 | sIn.read( &la, 1 ); | 214 | rawread( &la ); |
215 | } | 215 | } |
216 | else | 216 | else |
217 | { | 217 | { |
218 | c = la; | 218 | c = la; |
219 | if( c != '}' ) | 219 | if( c != '}' ) |
220 | sIn.read( &la, 1 ); | 220 | rawread( &la ); |
221 | } | ||
222 | } | ||
223 | |||
224 | void Bu::TafReader::rawread( char *c ) | ||
225 | { | ||
226 | if( sIn.read( c, 1 ) < 1 ) | ||
227 | { | ||
228 | if( sIn.isEOS() ) | ||
229 | { | ||
230 | throw TafException("%d:%d: Premature end of stream.", | ||
231 | iLine, iCol, c ); | ||
232 | } | ||
233 | else | ||
234 | { | ||
235 | throw TafException("%d:%d: No data read, but not end of stream?", | ||
236 | iLine, iCol, c ); | ||
237 | } | ||
221 | } | 238 | } |
222 | } | 239 | } |
223 | 240 | ||