From 5eb9938636b0ef004df7038eeae4fa98c0cb208e Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 25 Jan 2016 15:49:27 +0000 Subject: [PATCH] Fix more issues --- src/libutil/sqlite_utils.c | 2 +- src/lua/lua_sqlite3.c | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/libutil/sqlite_utils.c b/src/libutil/sqlite_utils.c index 58abbc67a..270922eb6 100644 --- a/src/libutil/sqlite_utils.c +++ b/src/libutil/sqlite_utils.c @@ -298,7 +298,7 @@ rspamd_sqlite3_open_or_create (rspamd_mempool_t *pool, const gchar *path, const rspamd_snprintf (lock_path, sizeof (lock_path), "%s.lock", path); - if (access (path, R_OK) == -1 && create_sql != NULL) { + if (access (path, R_OK) == -1) { flags |= SQLITE_OPEN_CREATE; create = TRUE; } diff --git a/src/lua/lua_sqlite3.c b/src/lua/lua_sqlite3.c index 708a74452..1f8eac143 100644 --- a/src/lua/lua_sqlite3.c +++ b/src/lua/lua_sqlite3.c @@ -99,16 +99,22 @@ lua_sqlite3_open (lua_State *L) { const gchar *path = luaL_checkstring (L, 1); sqlite3 *db, **pdb; + GError *err = NULL; if (path == NULL) { lua_pushnil (L); return 1; } - db = rspamd_sqlite3_open_or_create (NULL, path, NULL, NULL); + db = rspamd_sqlite3_open_or_create (NULL, path, NULL, &err); if (db == NULL) { + if (err) { + msg_err ("cannot open db: %e", err); + g_error_free (err); + } lua_pushnil (L); + return 1; } -- 2.39.5