From 14c0c38acd41bf7ef8d2413a727603711aac6cdc Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Thu, 2 Apr 2026 13:00:51 +0200 Subject: [PATCH] fix: Fix crash when loading MAM for a contact with empty db I think this bug happens when a user scrolls up a window, triggering iq_mam_request_older() to load older history, in the case when the database is empty for that contact. The initial MAM fetch is triggered when the window is opened which should get the latest history. Fixes: https://github.com/profanity-im/profanity/issues/2142 Signed-off-by: Michael Vetter --- src/xmpp/iq.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index bbc5b5d44..90107eac6 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -2636,10 +2636,13 @@ iq_mam_request_older(ProfChatWin* win) auto_gchar gchar* enddate = NULL; // If first message found - if (first_msg->timestamp) { + if (first_msg && first_msg->timestamp) { firstid = first_msg->stanzaid; enddate = g_date_time_format(first_msg->timestamp, mam_timestamp_format_string); } else { + if (first_msg) { + message_free(first_msg); + } return; }