From 1743bd0eacec94c6f6e3c89e16d0bd6d301017e8 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 29 Dec 2008 21:46:03 +0000 Subject: 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. --- src/tafreader.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'src/tafreader.cpp') 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() iCol++; if( c == '}' ) { - sIn.read( &c, 1 ); + rawread( &c ); if( c != '}' ) - sIn.read( &la, 1 ); + rawread( &la ); } else { c = la; if( c != '}' ) - sIn.read( &la, 1 ); + rawread( &la ); + } +} + +void Bu::TafReader::rawread( char *c ) +{ + if( sIn.read( c, 1 ) < 1 ) + { + if( sIn.isEOS() ) + { + throw TafException("%d:%d: Premature end of stream.", + iLine, iCol, c ); + } + else + { + throw TafException("%d:%d: No data read, but not end of stream?", + iLine, iCol, c ); + } } } -- cgit v1.2.3