Added support for calling throwException() from InputIterator and added a check for negative string sizes.

This commit is contained in:
Robert Osfield
2011-10-20 16:35:50 +00:00
parent 62888dba38
commit affe0b4a6d
3 changed files with 20 additions and 4 deletions

View File

@@ -692,6 +692,8 @@ InputStream::ReadType InputStream::start( InputIterator* inIterator )
if ( !_in )
throwException( "InputStream: Null stream specified." );
if ( getException() ) return type;
_in->setInputStream(this);
// Check OSG header information
unsigned int version = 0;

View File

@@ -145,11 +145,15 @@ public:
virtual void readString( std::string& s )
{
int size = 0; readInt( size );
if ( size )
if ( size>0 )
{
s.resize( size );
_in->read( (char*)s.c_str(), size );
}
else if ( size<0 )
{
throwException( "InputStream::readString() error, negative string size read." );
}
}
virtual void readStream( std::istream& (*fn)(std::istream&) ) {}