From b27d1a92b1488a21345bcb95fece31d441e242b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jaramago=20Fern=C3=A1ndez?= Date: Mon, 24 Feb 2025 16:48:44 +0100 Subject: [PATCH] Fix missing error handling for 'sqlite3_step' on 'SQLite3_result' Error handling for 'sqlite3_step' should be performed in a similar fashion as for 'sqlite3_exec'. Not handling these potential errors could result in invalid empty/incomplete resultsets when reading from the internal SQLite3 databases. --- lib/sqlite3db.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/sqlite3db.cpp b/lib/sqlite3db.cpp index 75c315e86..7dee44aaa 100644 --- a/lib/sqlite3db.cpp +++ b/lib/sqlite3db.cpp @@ -764,7 +764,13 @@ void SQLite3_result::add_column_definition(int a, const char *b) { * @return An integer representing the result of the operation (SQLITE_ROW on success). */ int SQLite3_result::add_row(sqlite3_stmt *stmt, bool skip) { - int rc=(*proxy_sqlite3_step)(stmt); + int rc = 0; + do { + rc = (*proxy_sqlite3_step)(stmt); + if (rc == SQLITE_BUSY || rc == SQLITE_LOCKED) { + usleep(USLEEP_SQLITE_LOCKED); + } + } while (rc == SQLITE_BUSY || rc == SQLITE_LOCKED); if (rc!=SQLITE_ROW) return rc; if (skip==false) { SQLite3_row *row=new SQLite3_row(columns);