From 505c6cb0621cf8094eb457b7aa0d50e3d7403154 Mon Sep 17 00:00:00 2001 From: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com> Date: Fri, 19 Apr 2024 13:23:13 +0700 Subject: [PATCH] ios: prevent a crash when exiting the app (#4041) * ios: prevent a crash when exiting the app * log --- apps/ios/SimpleXChat/API.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/ios/SimpleXChat/API.swift b/apps/ios/SimpleXChat/API.swift index cdd1008c13..e2f4adc60f 100644 --- a/apps/ios/SimpleXChat/API.swift +++ b/apps/ios/SimpleXChat/API.swift @@ -87,6 +87,11 @@ public func chatInitControllerRemovingDatabases() { public func chatCloseStore() { + // Prevent crash when exiting the app with already closed store (for example, after changing a database passpharase) + guard hasChatCtrl() else { + logger.error("chatCloseStore: already closed, chatCtrl is nil") + return + } let err = fromCString(chat_close_store(getChatCtrl())) if err != "" { logger.error("chatCloseStore error: \(err)")