Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix segfault when adding a layer
  • Loading branch information
pblottiere authored and nyalldawson committed Jun 2, 2020
1 parent 9fec526 commit 07eca3e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/core/qgssqliteutils.cpp
Expand Up @@ -126,7 +126,7 @@ QSet<QString> QgsSqliteUtils::uniqueFields( sqlite3 *connection, const QString &
QSet<QString> uniqueFieldsResults;
char *zErrMsg = 0;
std::vector<std::string> rows;
QString sql = sqlite3_mprintf( "select sql from sqlite_master where type='table' and name=%q", quotedIdentifier( tableName ).toStdString().c_str() );
QString sql = QgsSqlite3Mprintf( "select sql from sqlite_master where type='table' and name=%q", quotedIdentifier( tableName ).toStdString().c_str() );
auto cb = [ ](
void *data /* Data provided in the 4th argument of sqlite3_exec() */,
int /* The number of columns in row */,
Expand Down Expand Up @@ -171,8 +171,8 @@ QSet<QString> QgsSqliteUtils::uniqueFields( sqlite3 *connection, const QString &
rows.clear();

// Search indexes:
sql = sqlite3_mprintf( "SELECT sql FROM sqlite_master WHERE type='index' AND"
" tbl_name='%q' AND sql LIKE 'CREATE UNIQUE INDEX%%'" );
sql = QgsSqlite3Mprintf( "SELECT sql FROM sqlite_master WHERE type='index' AND"
" tbl_name='%q' AND sql LIKE 'CREATE UNIQUE INDEX%%'" );

This comment has been minimized.

Copy link
@3nids

3nids Jun 5, 2020

Member

I am getting a crash here since this change.

image

any idea?

This comment has been minimized.

Copy link
@nirvn

nirvn Jun 9, 2020

Contributor

@m-kuhn , that looks a lot like the crash on QField's arm64.

This comment has been minimized.

Copy link
@m-kuhn

m-kuhn Jun 9, 2020

Member

suspicious indeed

This comment has been minimized.

Copy link
@m-kuhn

m-kuhn Jun 9, 2020

Member

@3nids can you test with

QByteArray tableNameUtf8 = quotedIdentifier( tableName ).toUtf8();
QString sql = QgsSqlite3Mprintf( "select sql from sqlite_master where type='table' and name=%q", tableNameUtf8.constData() );
rc = sqlite3_exec( connection, sql.toUtf8(), cb, ( void * )&rows, &zErrMsg );
if ( rc != SQLITE_OK )
{
Expand Down

0 comments on commit 07eca3e

Please sign in to comment.