Skip to content

Commit

Permalink
Fix a couple of valgrind warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
  • Loading branch information
cernekee committed Oct 28, 2012
1 parent 1725ee9 commit cff6b33
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
4 changes: 0 additions & 4 deletions auth.c
Expand Up @@ -437,7 +437,6 @@ static int parse_auth_node(struct openconnect_info *vpninfo, xmlNode *xml_node,
ret = -EINVAL;
goto out;
}
vpninfo->redirect_url = strdup(form->action);

ret = parse_form(vpninfo, form, xml_node);
if (ret < 0)
Expand Down Expand Up @@ -577,9 +576,6 @@ int handle_auth_form(struct openconnect_info *vpninfo, struct oc_auth_form *form
}

if (vpninfo->csd_token && vpninfo->csd_ticket && vpninfo->csd_starturl && vpninfo->csd_waiturl) {
/* First, redirect to the stuburl -- we'll need to fetch and run that */
vpninfo->redirect_url = strdup(vpninfo->csd_stuburl);

/* AB: remove all cookies */
for (opt = vpninfo->cookies; opt; opt = next) {
next = opt->next;
Expand Down
12 changes: 8 additions & 4 deletions http.c
Expand Up @@ -618,8 +618,10 @@ static int run_csd_script(struct openconnect_info *vpninfo, char *buf, int bufle

free(vpninfo->csd_stuburl);
vpninfo->csd_stuburl = NULL;
free(vpninfo->urlpath);
vpninfo->urlpath = strdup(vpninfo->csd_waiturl +
(vpninfo->csd_waiturl[0] == '/' ? 1 : 0));
free(vpninfo->csd_waiturl);
vpninfo->csd_waiturl = NULL;
vpninfo->csd_scriptname = strdup(fname);

Expand Down Expand Up @@ -1098,16 +1100,18 @@ int openconnect_obtain_cookie(struct openconnect_info *vpninfo)
fetch_config(vpninfo, bu, fu, sha);
}
}
result = 0;

out:
free(form_buf);
free_auth_form(form);

if (vpninfo->csd_scriptname) {
unlink(vpninfo->csd_scriptname);
free(vpninfo->csd_scriptname);
vpninfo->csd_scriptname = NULL;
}
result = 0;

out:
free(form_buf);
free_auth_form(form);
return result;
}

Expand Down
7 changes: 7 additions & 0 deletions library.c
Expand Up @@ -109,13 +109,20 @@ void openconnect_vpninfo_free (struct openconnect_info *vpninfo)
free(vpninfo->redirect_url);
free(vpninfo->proxy_type);
free(vpninfo->proxy);

if (vpninfo->csd_scriptname) {
unlink(vpninfo->csd_scriptname);
free(vpninfo->csd_scriptname);
}
free(vpninfo->csd_token);
free(vpninfo->csd_ticket);
free(vpninfo->csd_stuburl);
free(vpninfo->csd_starturl);
free(vpninfo->csd_waiturl);
free(vpninfo->csd_preurl);
if (vpninfo->opaque_srvdata)
xmlFreeNode(vpninfo->opaque_srvdata);

/* These are const in openconnect itself, but for consistency of
the library API we do take ownership of the strings we're given,
and thus we have to free them too. */
Expand Down

0 comments on commit cff6b33

Please sign in to comment.