diff options
author | Michael Vetter <jubalh@iodoru.org> | 2020-04-20 15:31:48 +0200 |
---|---|---|
committer | Michael Vetter <jubalh@iodoru.org> | 2020-04-20 15:31:48 +0200 |
commit | 9e460973faaa87f2ca18de6ef6f033f7aa079bb2 (patch) | |
tree | 32c2a5bf8aadf2b935e69d1427b73f0f6f8f6569 /src/xmpp | |
parent | 95b75a29485706dd25886f4e077ee0d2aa08cc97 (diff) | |
download | profani-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.c | 16 |
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); |