]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-sql: Add asserts to make sure refcount unexpectedly doesn't drop below 1
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 20 Sep 2019 09:04:37 +0000 (12:04 +0300)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 20 Sep 2019 09:04:37 +0000 (12:04 +0300)
src/lib-sql/sql-api.c

index 2b28623f962017df17d310c78db560ac79b84ea4..43b2888ed204d83c7222c084f0b7d04ea9233444 100644 (file)
@@ -118,6 +118,7 @@ void sql_init_common(struct sql_db *db)
 
 void sql_ref(struct sql_db *db)
 {
+       i_assert(db->refcount > 0);
        db->refcount++;
 }
 
@@ -152,6 +153,7 @@ void sql_unref(struct sql_db **_db)
 
        *_db = NULL;
 
+       i_assert(db->refcount > 0);
        if (db->v.unref != NULL)
                db->v.unref(db);
        if (--db->refcount > 0)