dovecot-1.2: sqlite crashed with dict server. Patch by Bernhard ...

dovecot at dovecot.org dovecot at dovecot.org
Fri Aug 22 01:15:20 EEST 2008


details:   http://hg.dovecot.org/dovecot-1.2/rev/277aadb0ef8c
changeset: 8102:277aadb0ef8c
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Aug 22 01:15:13 2008 +0300
description:
sqlite crashed with dict server. Patch by Bernhard Herzog.

diffstat:

1 file changed, 15 insertions(+), 6 deletions(-)
src/lib-sql/driver-sqlite.c |   21 +++++++++++++++------

diffs (41 lines):

diff -r 06cb6f9d3054 -r 277aadb0ef8c src/lib-sql/driver-sqlite.c
--- a/src/lib-sql/driver-sqlite.c	Thu Aug 21 07:36:40 2008 +0300
+++ b/src/lib-sql/driver-sqlite.c	Fri Aug 22 01:15:13 2008 +0300
@@ -124,6 +124,9 @@ static void driver_sqlite_exec(struct sq
 {
 	struct sqlite_db *db = (struct sqlite_db *)_db;
 
+	if (driver_sqlite_connect(_db) < 0)
+		return;
+
 	db->rc = sqlite3_exec(db->sqlite, query, NULL, 0, NULL);
 	if (db->rc != SQLITE_OK) {
 		i_error("sqlite: exec(%s) failed: %s (%d)",
@@ -152,15 +155,21 @@ driver_sqlite_query_s(struct sql_db *_db
 
 	result = i_new(struct sqlite_result, 1);
 
-	rc = sqlite3_prepare(db->sqlite, query, -1, &result->stmt, NULL);
-	if (rc == SQLITE_OK) {
-		result->api = driver_sqlite_result;
-		result->cols = sqlite3_column_count(result->stmt);
-		result->row = i_new(const char *, result->cols);
-	} else {
+	if (driver_sqlite_connect(_db) < 0) {
 		result->api = driver_sqlite_error_result;
 		result->stmt = NULL;
 		result->cols = 0;
+	} else {
+		rc = sqlite3_prepare(db->sqlite, query, -1, &result->stmt, NULL);
+		if (rc == SQLITE_OK) {
+			result->api = driver_sqlite_result;
+			result->cols = sqlite3_column_count(result->stmt);
+			result->row = i_new(const char *, result->cols);
+		} else {
+			result->api = driver_sqlite_error_result;
+			result->stmt = NULL;
+			result->cols = 0;
+		}
 	}
 	result->api.db = _db;
 


More information about the dovecot-cvs mailing list