Fix potential segfault.

It's not guaranteed that `log_database_get_limits_info()` returns a
non-NULL value or that `timestamp` is non-NULL.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
This commit is contained in:
Steffen Jaeckel
2026-03-12 10:38:15 +01:00
parent ab3f58b3a3
commit ff65db0b10

View File

@@ -2668,8 +2668,10 @@ _iq_mam_request(ProfChatWin* win, GDateTime* startdate, GDateTime* enddate)
if (connection_supports(XMPP_FEATURE_MAM2) == FALSE) { if (connection_supports(XMPP_FEATURE_MAM2) == FALSE) {
log_warning("Server doesn't advertise %s feature.", XMPP_FEATURE_MAM2); log_warning("Server doesn't advertise %s feature.", XMPP_FEATURE_MAM2);
cons_show_error("Server doesn't support MAM (%s).", XMPP_FEATURE_MAM2); cons_show_error("Server doesn't support MAM (%s).", XMPP_FEATURE_MAM2);
g_date_time_unref(startdate); if (startdate)
g_date_time_unref(enddate); g_date_time_unref(startdate);
if (enddate)
g_date_time_unref(enddate);
return; return;
} }
@@ -2718,8 +2720,12 @@ void
iq_mam_request(ProfChatWin* win, GDateTime* enddate) iq_mam_request(ProfChatWin* win, GDateTime* enddate)
{ {
ProfMessage* last_msg = log_database_get_limits_info(win->barejid, TRUE); ProfMessage* last_msg = log_database_get_limits_info(win->barejid, TRUE);
GDateTime* startdate = g_date_time_ref(last_msg->timestamp); GDateTime* startdate = NULL;
message_free(last_msg); if (last_msg) {
if (last_msg->timestamp)
startdate = g_date_time_ref(last_msg->timestamp);
message_free(last_msg);
}
// Save request for later if disco items haven't been received yet // Save request for later if disco items haven't been received yet
if (!received_disco_items) { if (!received_disco_items) {