about summary refs log tree commit diff stats
path: root/src/xmpp
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2020-04-20 15:31:48 +0200
committerMichael Vetter <jubalh@iodoru.org>2020-04-20 15:31:48 +0200
commit9e460973faaa87f2ca18de6ef6f033f7aa079bb2 (patch)
tree32c2a5bf8aadf2b935e69d1427b73f0f6f8f6569 /src/xmpp
parent95b75a29485706dd25886f4e077ee0d2aa08cc97 (diff)
downloadprofani-tty-9e460973faaa87f2ca18de6ef6f033f7aa079bb2.tar.gz
Fix potential memleak in stanza_create_caps_from_query_element()
Each of those should only occur one time. But let's make sure we only
write/alloc one time to be on the safe side.
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/stanza.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/xmpp/stanza.c b/src/xmpp/stanza.c
index a247cfc4..3a7e39c8 100644
--- a/src/xmpp/stanza.c
+++ b/src/xmpp/stanza.c
@@ -1784,13 +1784,21 @@ stanza_create_caps_from_query_element(xmpp_stanza_t *query)
                 formField = field->data;
                 if (formField->values) {
                     if (strcmp(formField->var, "software") == 0) {
-                        software = strdup(formField->values->data);
+                        if (software == NULL) {
+                            software = strdup(formField->values->data);
+                        }
                     } else if (strcmp(formField->var, "software_version") == 0) {
-                        software_version = strdup(formField->values->data);
+                        if (software_version == NULL) {
+                            software_version = strdup(formField->values->data);
+                        }
                     } else if (strcmp(formField->var, "os") == 0) {
-                        os = strdup(formField->values->data);
+                        if (os == NULL) {
+                            os = strdup(formField->values->data);
+                        }
                     } else if (strcmp(formField->var, "os_version") == 0) {
-                        os_version = strdup(formField->values->data);
+                        if (os_version == NULL) {
+                            os_version = strdup(formField->values->data);
+                        }
                     }
                 }
                 field = g_slist_next(field);