summaryrefslogtreecommitdiff
path: root/src/rexmpp_roster.c
diff options
context:
space:
mode:
authordefanor <defanor@uberspace.net>2023-06-09 14:43:15 +0300
committerdefanor <defanor@uberspace.net>2023-06-09 14:43:15 +0300
commit2d4110996bea53a9568b750d00d4dcdcc3907bc6 (patch)
treec0501e57847a0a9b1b415c17f2a6816a40eae3c2 /src/rexmpp_roster.c
parent122b13ec955deb718aca280112584b645c9caea0 (diff)
Avoid direct strdup of values returned by rexmpp_xml_find_attr_val
Better to check those to not be NULL first.
Diffstat (limited to 'src/rexmpp_roster.c')
-rw-r--r--src/rexmpp_roster.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/rexmpp_roster.c b/src/rexmpp_roster.c
index db09ff0..6bc05fc 100644
--- a/src/rexmpp_roster.c
+++ b/src/rexmpp_roster.c
@@ -91,7 +91,11 @@ void rexmpp_roster_set (rexmpp_t *s, rexmpp_xml_t *query) {
if (s->roster_ver != NULL) {
free(s->roster_ver);
}
- s->roster_ver = strdup(rexmpp_xml_find_attr_val(query, "ver"));
+ const char *roster_ver = rexmpp_xml_find_attr_val(query, "ver");
+ s->roster_ver = NULL;
+ if (roster_ver != NULL) {
+ s->roster_ver = strdup(roster_ver);
+ }
s->roster_items = rexmpp_xml_clone_list(query->alt.elem.children);
if (s->roster_modify_cb != NULL) {
rexmpp_xml_t *item;