Skip to content

Commit 18c86ac

Browse files
committed
avoid memory leaks; remove union in oauth2_jose_jwks_provider_t
Signed-off-by: Hans Zandbelt <hans.zandbelt@openidc.com>
1 parent 961f656 commit 18c86ac

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

src/jose_int.h

+13-9
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,19 @@ typedef oauth2_jose_jwk_list_t *(
6060
typedef struct oauth2_jose_jwks_provider_t {
6161
oauth2_jose_jwks_provider_type_t type;
6262
oauth2_jose_jwks_resolve_cb_t *resolve;
63-
union {
64-
oauth2_uri_ctx_t *jwks_uri;
65-
oauth2_jose_jwk_list_t *jwks;
66-
struct {
67-
char *alb_arn;
68-
char *alb_base_url;
69-
};
70-
};
71-
// struct oauth2_jose_jwks_provider_t *next;
63+
64+
// NB: avoid union because of compiler/memory issues
65+
66+
// OAUTH2_JOSE_JWKS_PROVIDER_JWKS_URI and
67+
// OAUTH2_JOSE_JWKS_PROVIDER_ECKEY_URI
68+
oauth2_uri_ctx_t *jwks_uri;
69+
70+
// OAUTH2_JOSE_JWKS_PROVIDER_LIST
71+
oauth2_jose_jwk_list_t *jwks;
72+
73+
// OAUTH2_JOSE_JWKS_PROVIDER_AWS_ALB
74+
char *alb_arn;
75+
char *alb_base_url;
7276
} oauth2_jose_jwks_provider_t;
7377

7478
_OAUTH2_CFG_CTX_TYPE_START(oauth2_jose_jwt_verify_ctx)

test/check_oauth2.c

+1
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,7 @@ START_TEST(test_oauth2_verify_aws_alb)
827827
ck_assert_int_eq(rc, true);
828828

829829
oauth2_cfg_token_verify_free(_log, verify);
830+
oauth2_mem_free(options);
830831
oauth2_mem_free(url);
831832
json_decref(json_payload);
832833
}

0 commit comments

Comments
 (0)