Skip to content

Commit dc6ba5b

Browse files
committed
fix a couple of memory leaks
1 parent 10a2f43 commit dc6ba5b

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

library/external_auth.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ extern int ziti_ext_auth_token(ziti_context ztx, const char *token) {
167167
NEWP(jwt, zt_jwt);
168168
if (zt_jwt_parse(token, jwt) != 0) {
169169
ZTX_LOG(WARN, "failed to parse JWT token");
170+
free(jwt);
170171
return ZITI_JWT_INVALID;
171172
}
172173
ZTX_LOG(DEBUG, "received access token: %s", json_object_get_string(jwt->claims));

library/utils.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -778,11 +778,9 @@ cstr jwt_issuer(const char *jwt) {
778778
assert(jwt);
779779
json_object *claims = json_tokener_parse(jwt_payload(jwt));
780780
json_object *iss = json_object_object_get(claims, "iss");
781-
if (iss) {
782-
return cstr_from(json_object_get_string(iss));
783-
}
784-
785-
return cstr_lit("<unknown>");
781+
cstr result = iss ? cstr_from(json_object_get_string(iss)) : cstr_lit("<unknown>");
782+
json_object_put(claims);
783+
return result;
786784
}
787785

788786
const char *jwt_payload(const char *jwt) {

0 commit comments

Comments
 (0)