Skip to content

Commit

Permalink
fix memory leaks (start and dns) caught by static analyzer
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Lenski <dlenski@gmail.com>
  • Loading branch information
dlenski committed Nov 29, 2020
1 parent 9ebd392 commit 510c0f0
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions gpst.c
Expand Up @@ -542,12 +542,10 @@ static int gpst_parse_config_xml(struct openconnect_info *vpninfo, xmlNode *xml_
buf_free(domains);
} else if (!xmlnode_get_val(xml_node, "include-split-tunneling-domain", &s)) {
/* Whitespace separated string (e.g. " *.domain.com:443\n *.otherdomain.com\n") */
char *start, *end, *colon;
char *start, *end, *colon, *save_start;

for (start=s; *start; start=end) {
struct oc_split_include *dns = malloc(sizeof(*dns));
if (!dns)
break;
struct oc_split_include *dns;

/* Find start and end */
while (*start && isspace(*start))
Expand Down Expand Up @@ -576,8 +574,12 @@ static int gpst_parse_config_xml(struct openconnect_info *vpninfo, xmlNode *xml_
*colon = '\0';
}

start = strdup(start);
dns = malloc(sizeof(*dns));
if (!dns)
break;
save_start = start;
dns->route = add_option(vpninfo, "split-dns", &start);
start = save_start;
dns->next = vpninfo->ip_info.split_dns;
vpninfo->ip_info.split_dns = dns;
}
Expand Down

0 comments on commit 510c0f0

Please sign in to comment.