]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
Fix resource leak identified by Coverity Scan
authorDimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
Mon, 6 Nov 2023 11:07:37 +0000 (12:07 +0100)
committerDimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
Mon, 6 Nov 2023 13:31:15 +0000 (14:31 +0100)
Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
f5.c

diff --git a/f5.c b/f5.c
index 634a95f010a1b6de5045e7d751a7b39583624b9c..0d53ab4266e1cc752458cec04b7c4578b0c6a058 100644 (file)
--- 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 */