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 <jubalh@iodoru.org>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user