Skip to content

Commit

Permalink
Fix memory leak in QgsPostgresProvider::createEmptyLayer
Browse files Browse the repository at this point in the history
(cherry-picked from 8ce519)
  • Loading branch information
nyalldawson committed Feb 26, 2018
1 parent 4f1c100 commit d6cf2e5
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/providers/postgres/qgspostgresprovider.cpp
Expand Up @@ -3919,13 +3919,12 @@ QgsVectorLayerExporter::ExportError QgsPostgresProvider::createEmptyLayer( const

// use the provider to edit the table
dsUri.setDataSource( schemaName, tableName, geometryColumn, QString(), primaryKey );
QgsPostgresProvider *provider = new QgsPostgresProvider( dsUri.uri( false ) );
std::unique_ptr< QgsPostgresProvider > provider = qgis::make_unique< QgsPostgresProvider >( dsUri.uri( false ) );
if ( !provider->isValid() )
{
if ( errorMessage )
*errorMessage = QObject::tr( "Loading of the layer %1 failed" ).arg( schemaTableName );

delete provider;
return QgsVectorLayerExporter::ErrInvalidLayer;
}

Expand Down Expand Up @@ -3986,7 +3985,6 @@ QgsVectorLayerExporter::ExportError QgsPostgresProvider::createEmptyLayer( const
if ( errorMessage )
*errorMessage = QObject::tr( "Unsupported type for field %1" ).arg( fld.name() );

delete provider;
return QgsVectorLayerExporter::ErrAttributeTypeUnsupported;
}

Expand All @@ -4006,7 +4004,6 @@ QgsVectorLayerExporter::ExportError QgsPostgresProvider::createEmptyLayer( const
if ( errorMessage )
*errorMessage = QObject::tr( "Creation of fields failed" );

delete provider;
return QgsVectorLayerExporter::ErrAttributeCreationFailed;
}

Expand Down

0 comments on commit d6cf2e5

Please sign in to comment.