From 25f43caafb44ba9e97b7e9c4c9d0b0bd212130f3 Mon Sep 17 00:00:00 2001 From: Vlad Patrascu Date: Fri, 28 Jan 2022 17:58:49 +0200 Subject: [PATCH] dialog: fix crash when dropping unsynced dialogs (cherry picked from commit da47168d02a9359de5f95ab83f6f040bbb7c9db9) --- modules/dialog/dlg_replication.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/dialog/dlg_replication.c b/modules/dialog/dlg_replication.c index f2f8aebf1e3..d1f19f1958d 100644 --- a/modules/dialog/dlg_replication.c +++ b/modules/dialog/dlg_replication.c @@ -1110,13 +1110,15 @@ struct dlg_cell *drop_dlg(struct dlg_cell *dlg, int i) unref++; if (dlg_db_mode != DB_MODE_NONE) { - if (dlg_db_mode != DB_MODE_SHUTDOWN) { + if (dlg_db_mode != DB_MODE_SHUTDOWN && + !(dlg->flags&DLG_FLAG_DB_DELETED)) { dlg->flags &= ~DLG_FLAG_NEW; remove_dialog_from_db(dlg); dlg->flags |= DLG_FLAG_DB_DELETED; } - if (dlg_db_mode == DB_MODE_DELAYED) + if (dlg_db_mode == DB_MODE_DELAYED && + !(dlg->flags&DLG_FLAG_DB_DELETED)) unref++; }