From bc38ddf8fa835a6ba5c5bd03a3fc63cadb7615ee Mon Sep 17 00:00:00 2001 From: John Hernandez <129467592+H3rnand3zzz@users.noreply.github.com> Date: Tue, 7 Nov 2023 13:35:56 +0100 Subject: [PATCH] Improve handling of NULL pointers in DB Fix crash that occurs when message fetched from the database is NULL. Introduced in this commit 89dc7a46f13b452a1dba7fa8237ad5efbf8f3a2d Previous fix attempt 6d17b4eeb5eb2af8944d77ea0abfb7aa2cf08e27 --- src/database.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/database.c b/src/database.c index 7b95fb2c..3a0621c9 100644 --- a/src/database.c +++ b/src/database.c @@ -375,7 +375,7 @@ log_database_get_previous_chat(const gchar* const contact_barejid, const char* s ProfMessage* msg = message_init(); msg->from_jid = jid_create(from); msg->to_jid = jid_create(to_jid); - msg->plain = _db_strdup(message); + msg->plain = strdup(message ?: ""); msg->timestamp = g_date_time_new_from_iso8601(date, NULL); msg->type = _get_message_type_type(type); msg->enc = _get_message_enc_type(encryption);