From Cedric Pinson, "Here a fix about a leak in InputStream::decompress
I changed _in->setStream( new std::stringstream(data) ); to _dataDecompress = new std::stringstream(data); _in->setStream( _dataDecompress ); Then when the destructor is of InputStream is called I delete the dataDecompress stringstream. "
This commit is contained in:
parent
d9bd6c977e
commit
0c84f2deff
@ -167,6 +167,9 @@ protected:
|
||||
osg::ref_ptr<InputIterator> _in;
|
||||
osg::ref_ptr<InputException> _exception;
|
||||
osg::ref_ptr<const osgDB::Options> _options;
|
||||
|
||||
// store here to avoid a new and a leak in InputStream::decompress
|
||||
std::stringstream* _dataDecompress;
|
||||
};
|
||||
|
||||
void InputStream::throwException( const std::string& msg )
|
||||
|
@ -24,7 +24,7 @@ using namespace osgDB;
|
||||
static std::string s_lastSchema;
|
||||
|
||||
InputStream::InputStream( const osgDB::Options* options )
|
||||
: _byteSwap(0), _useFloatMatrix(true), _useSchemaData(false), _forceReadingImage(false)
|
||||
: _byteSwap(0), _useFloatMatrix(true), _useSchemaData(false), _forceReadingImage(false), _dataDecompress(0)
|
||||
{
|
||||
if ( !options ) return;
|
||||
_options = options;
|
||||
@ -73,6 +73,8 @@ InputStream::InputStream( const osgDB::Options* options )
|
||||
|
||||
InputStream::~InputStream()
|
||||
{
|
||||
if (_dataDecompress)
|
||||
delete _dataDecompress;
|
||||
}
|
||||
|
||||
InputStream& InputStream::operator>>( osg::Vec2b& v )
|
||||
@ -673,7 +675,8 @@ void InputStream::decompress()
|
||||
throwException( "InputStream: Failed to decompress stream." );
|
||||
if ( getException() ) return;
|
||||
|
||||
_in->setStream( new std::stringstream(data) );
|
||||
_dataDecompress = new std::stringstream(data);
|
||||
_in->setStream( _dataDecompress );
|
||||
_fields.pop_back();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user