From 77ac1a997fb05b81a4bc67fe3bd64862e4e47392 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com> Date: Mon, 6 Nov 2023 12:07:37 +0100 Subject: [PATCH] Fix resource leak identified by Coverity Scan Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com> --- f5.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/f5.c b/f5.c index 634a95f0..0d53ab42 100644 --- a/f5.c +++ b/f5.c @@ -203,8 +203,11 @@ static struct oc_auth_form *parse_json_form(struct openconnect_info *vpninfo, js continue; struct oc_form_opt *opt = calloc(1, sizeof(*opt)); - if (!opt) + if (!opt) { + nomem2: + free(opt); goto nomem; + } for (int j = 0; j < f->u.object.length; j++) { json_value *subval = f->u.object.values[j].value; @@ -225,7 +228,7 @@ static struct oc_auth_form *parse_json_form(struct openconnect_info *vpninfo, js subval->type = json_null, subval->u.string.ptr = NULL; /* XX */ } else if (!strcmp(subname, "caption") && subval->type == json_string) { if (asprintf(&opt->label, "%s:", subval->u.string.ptr) < 0) - goto nomem; + goto nomem2; } else if (!strcmp(subname, "value") && subval->type == json_string && subval->u.string.length > 0) { opt->_value = subval->u.string.ptr; subval->type = json_null, subval->u.string.ptr = NULL; /* XX */ -- 2.50.1