Skip to content

Commit e7c0728

Browse files
committed
Fix memory leak
1 parent c1b9321 commit e7c0728

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/ngx_http_auth_jwt_module.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ static ngx_int_t ngx_http_auth_jwt_handler(ngx_http_request_t *r)
149149
char* return_url;
150150
ngx_http_auth_jwt_loc_conf_t *jwtcf;
151151
u_char *keyBinary;
152+
// For clearing it later on
153+
char* pub_key = NULL;
152154
jwt_t *jwt = NULL;
153155
int jwtParseReturnCode;
154156
jwt_alg_t alg;
@@ -224,7 +226,7 @@ static ngx_int_t ngx_http_auth_jwt_handler(ngx_http_request_t *r)
224226
}
225227

226228
// Read pub key
227-
char *pub_key = malloc(key_size + 1);
229+
pub_key = malloc(key_size + 1);
228230
size_t bytes_read = fread(pub_key, 1, key_size, file);
229231
fclose(file);
230232

@@ -296,6 +298,8 @@ static ngx_int_t ngx_http_auth_jwt_handler(ngx_http_request_t *r)
296298

297299
jwt_free(jwt);
298300

301+
if (pub_key == NULL) free(pub_key);
302+
299303
return NGX_OK;
300304

301305
redirect:

0 commit comments

Comments
 (0)