From 39cdfdb99a7ad1b38863d94f12ec80ad9ca5cc43 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Sun, 30 Apr 2017 12:38:31 +0200 Subject: [PATCH] Bind correctly Signed-off-by: Sebastian Ramacher --- zathura/database-sqlite.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/zathura/database-sqlite.c b/zathura/database-sqlite.c index 674d3e3..c72b1cf 100644 --- a/zathura/database-sqlite.c +++ b/zathura/database-sqlite.c @@ -778,8 +778,14 @@ sqlite_get_recent_files(zathura_database_t* db, int max, const char* basepath) max = INT_MAX; } - if (sqlite3_bind_int(stmt, 1, max) != SQLITE_OK && - (basepath == NULL || sqlite3_bind_text(stmt, 2, basepath, -1, NULL) != SQLITE_OK)) { + bool failed = false; + if (basepath != NULL) { + failed = sqlite3_bind_int(stmt, 2, max) != SQLITE_OK || sqlite3_bind_text(stmt, 1, basepath, -1, NULL) != SQLITE_OK; + } else { + failed = sqlite3_bind_int(stmt, 1, max) != SQLITE_OK; + } + + if (failed == true) { sqlite3_finalize(stmt); girara_error("Failed to bind arguments."); return false;