Skip to content
Permalink
Browse files

Fix memory leak in QgsPostgresProvider::createEmptyLayer

  • Loading branch information
nyalldawson committed Feb 26, 2018
1 parent fb3e1c3 commit 8ce519d2ad68e141bc62da22aac1d40de6ccca7d
Showing with 1 addition and 4 deletions.
  1. +1 −4 src/providers/postgres/qgspostgresprovider.cpp
@@ -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;
}

@@ -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;
}

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

delete provider;
return QgsVectorLayerExporter::ErrAttributeCreationFailed;
}

0 comments on commit 8ce519d

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