about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2020-02-25 15:54:44 +0100
committerMichael Vetter <jubalh@iodoru.org>2020-02-25 15:54:44 +0100
commit62730367d6fe064cae38ba3930feec8575e77029 (patch)
tree90cdbf96236f4b4bf74e960831dc099511a58ea8 /src
parente9c5c1979d836ed75c37d48651710b4fd125cfb2 (diff)
downloadprofani-tty-62730367d6fe064cae38ba3930feec8575e77029.tar.gz
Fix memleak in stanza_get_oldest_delay
We need to unref the temp datetimes again.
Diffstat (limited to 'src')
-rw-r--r--src/xmpp/stanza.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/xmpp/stanza.c b/src/xmpp/stanza.c
index 7b0db5c7..06620c53 100644
--- a/src/xmpp/stanza.c
+++ b/src/xmpp/stanza.c
@@ -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);
+            }
         }
     }