1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Fix memleak in stanza_get_oldest_delay

We need to unref the temp datetimes again.
This commit is contained in:
Michael Vetter 2020-02-25 15:54:44 +01:00
parent e9c5c1979d
commit 62730367d6

View File

@ -1286,15 +1286,27 @@ stanza_get_oldest_delay(xmpp_stanza_t *const stanza)
if (child_name && strcmp(child_name, STANZA_NAME_DELAY) == 0) {
GDateTime *tmp = _stanza_get_delay_timestamp_xep0203(child);
if (!oldest || g_date_time_compare(oldest, tmp) == 1)
if (oldest == NULL) {
oldest = tmp;
} else if (g_date_time_compare(oldest, tmp) == 1) {
g_date_time_unref(oldest);
oldest = tmp;
} else {
g_date_time_unref(tmp);
}
}
if (child_name && strcmp(child_name, STANZA_NAME_X) == 0) {
GDateTime *tmp = _stanza_get_delay_timestamp_xep0091(child);
if (!oldest || g_date_time_compare(oldest, tmp) == 1)
if (oldest == NULL) {
oldest = tmp;
} else if (g_date_time_compare(oldest, tmp) == 1) {
g_date_time_unref(oldest);
oldest = tmp;
} else {
g_date_time_unref(tmp);
}
}
}