From: Aki Tuomi Date: Wed, 6 Sep 2023 05:34:51 +0000 (+0300) Subject: lib-sql: driver-mysql - Use API state to check if there is connection X-Git-Tag: 2.4.0~2599 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2160b909e67c32eee5509222fc03601402ca86a8;p=thirdparty%2Fdovecot%2Fcore.git lib-sql: driver-mysql - Use API state to check if there is connection db->mysql cannot be NULL. Broken in d0a2a8fd48a6c844a69381552db85fced0ae1d48 --- diff --git a/src/lib-sql/driver-mysql.c b/src/lib-sql/driver-mysql.c index 9a7855eeba..94beef3140 100644 --- a/src/lib-sql/driver-mysql.c +++ b/src/lib-sql/driver-mysql.c @@ -371,7 +371,7 @@ driver_mysql_escape_string(struct sql_db *_db, const char *string) (void)sql_connect(&db->api); } - if (db->mysql == NULL) { + if (_db->state == SQL_DB_STATE_DISCONNECTED) { /* FIXME: we don't have a valid connection, so fallback to using default escaping. the next query will most likely fail anyway so it shouldn't matter that much