Skip to content
Permalink
Browse files

Fix coverity issues:

- possible use after free
- uninitialized member
  • Loading branch information
nyalldawson committed Jan 10, 2016
1 parent 17793c3 commit bc89bdb17003a148672068c8a42ec9f39a1183b6
@@ -52,19 +52,24 @@ bool QgsFeaturePool::get( QgsFeatureId id , QgsFeature& feature )
{
QMutexLocker lock( &mLayerMutex );
QgsFeature* pfeature = mFeatureCache.object( id );
if ( !pfeature )
if ( pfeature )
{
// Get new feature
pfeature = new QgsFeature();
// TODO: avoid always querying all attributes (attribute values are needed when merging by attribute)
if ( !mLayer->getFeatures( QgsFeatureRequest( id ) ).nextFeature( *pfeature ) )
{
delete pfeature;
return false;
}
mFeatureCache.insert( id, pfeature );
//feature was cached
feature = *pfeature;
}
feature = *pfeature;

// Feature not in cache, retrieve from layer
pfeature = new QgsFeature();
// TODO: avoid always querying all attributes (attribute values are needed when merging by attribute)
if ( !mLayer->getFeatures( QgsFeatureRequest( id ) ).nextFeature( *pfeature ) )
{
delete pfeature;
return false;
}
//make a copy of pfeature into feature parameter
feature = QgsFeature( *pfeature );
//ownership of pfeature is transferred to cache
mFeatureCache.insert( id, pfeature );
return true;
}

@@ -105,6 +105,7 @@ struct VTable
, mSlotToFunction( invalidateTable, this )
, mName( layer->name() )
, mPkColumn( -1 )
, mCrs( -1 )
, mValid( true )
{
if ( mLayer )
@@ -123,6 +124,7 @@ struct VTable
, mName( name )
, mEncoding( encoding )
, mPkColumn( -1 )
, mCrs( -1 )
, mValid( true )
{
mProvider = static_cast<QgsVectorDataProvider*>( QgsProviderRegistry::instance()->provider( provider, source ) );

0 comments on commit bc89bdb

Please sign in to comment.
You can’t perform that action at this time.