diff --git a/src/core/qgsapplication.cpp b/src/core/qgsapplication.cpp index c45294aec2f..9bb30759c61 100644 --- a/src/core/qgsapplication.cpp +++ b/src/core/qgsapplication.cpp @@ -307,12 +307,16 @@ void QgsApplication::init( QString profileFolder ) // append local user-writable folder as a proj search path QStringList currentProjSearchPaths = QgsProjUtils::searchPaths(); currentProjSearchPaths.append( qgisSettingsDirPath() + QStringLiteral( "proj" ) ); - const char **newPaths = new const char *[currentProjSearchPaths.length()]; + char **newPaths = new char *[currentProjSearchPaths.length()]; for ( int i = 0; i < currentProjSearchPaths.count(); ++i ) { - newPaths[i] = currentProjSearchPaths.at( i ).toUtf8().constData(); + newPaths[i] = CPLStrdup( currentProjSearchPaths.at( i ).toUtf8().constData() ); } proj_context_set_search_paths( nullptr, currentProjSearchPaths.count(), newPaths ); + for ( int i = 0; i < currentProjSearchPaths.count(); ++i ) + { + CPLFree( newPaths[i] ); + } delete [] newPaths; #endif