aboutsummaryrefslogtreecommitdiff
path: root/src/tafreader.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2008-12-29 21:46:03 +0000
committerMike Buland <eichlan@xagasoft.com>2008-12-29 21:46:03 +0000
commit1743bd0eacec94c6f6e3c89e16d0bd6d301017e8 (patch)
treea4de5c4bf9ebb8b9181daa8ec52c697dc3e1ff63 /src/tafreader.cpp
parentf461b3c1839e5cfc85685ed1cb828ecaa74d6912 (diff)
downloadlibbu++-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 '')
-rw-r--r--src/tafreader.cpp23
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
224void 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