From: Ralph Corderoy Date: Tue, 12 Sep 2017 13:55:16 +0000 (+0100) Subject: mh_oauth_cred_fn()'s return value no longer needs duplicating. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/b080f5bec1263d354ca4943e2bc9670cb1e9cfa7?ds=sidebyside mh_oauth_cred_fn()'s return value no longer needs duplicating. It now returns a fresh allocation so that can be used directly rather than obtaining another copy. --- diff --git a/h/oauth.h b/h/oauth.h index e6873df4..7aa112c5 100644 --- a/h/oauth.h +++ b/h/oauth.h @@ -220,7 +220,7 @@ mh_oauth_cred_free(mh_oauth_cred *cred); * * Never returns NULL. */ -const char * +char * mh_oauth_cred_fn(const char *svc_name); /* diff --git a/sbr/oauth.c b/sbr/oauth.c index ec485cdf..8a9893eb 100755 --- a/sbr/oauth.c +++ b/sbr/oauth.c @@ -145,7 +145,7 @@ mh_oauth_do_xoauth(const char *user, const char *svc, unsigned char **oauth_res, if (log != NULL) mh_oauth_log_to(stderr, ctx); - fn = mh_xstrdup(mh_oauth_cred_fn(svc)); + fn = mh_oauth_cred_fn(svc); fp = lkfopendata(fn, "r+", &failed_to_lock); if (fp == NULL) { if (errno == ENOENT) { diff --git a/sbr/oauth_prof.c b/sbr/oauth_prof.c index 0d4336d8..51a5f7ac 100644 --- a/sbr/oauth_prof.c +++ b/sbr/oauth_prof.c @@ -128,7 +128,7 @@ mh_oauth_get_service_info(const char *svc_name, mh_oauth_service_info *svcinfo, } /* Return value must be free(3)'d. */ -const char * +char * mh_oauth_cred_fn(const char *svc) { char *key = mh_oauth_node_name_for_svc("credential-file", svc); diff --git a/uip/mhlogin.c b/uip/mhlogin.c index e78ae68f..aee2c1eb 100644 --- a/uip/mhlogin.c +++ b/uip/mhlogin.c @@ -71,7 +71,7 @@ do_login(const char *svc, const char *user, const char *browser, int snoop) mh_oauth_log_to(stderr, ctx); } - fn = mh_xstrdup(mh_oauth_cred_fn(svc)); + fn = mh_oauth_cred_fn(svc); if ((url = mh_oauth_get_authorize_url(ctx)) == NULL) { adios(NULL, "%s", mh_oauth_get_err_string(ctx)); diff --git a/uip/sendsbr.c b/uip/sendsbr.c index 0af6f63a..75a25ed4 100644 --- a/uip/sendsbr.c +++ b/uip/sendsbr.c @@ -823,7 +823,7 @@ setup_oauth_params(char *vec[], int *vecp, const char *auth_svc, vec[(*vecp)++] = mh_xstrdup("-authservice"); vec[(*vecp)++] = mh_xstrdup(auth_svc); vec[(*vecp)++] = mh_xstrdup("-oauthcredfile"); - vec[(*vecp)++] = mh_xstrdup(mh_oauth_cred_fn(auth_svc)); + vec[(*vecp)++] = mh_oauth_cred_fn(auth_svc); vec[(*vecp)++] = mh_xstrdup("-oauthclientid"); vec[(*vecp)++] = getcpy(svc.client_id); vec[(*vecp)++] = mh_xstrdup("-oauthclientsecret");