Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jws: _cjose_jws_build_dig_hmac_sha: fix jws->dig reuse memory leak fix #117

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/jws.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ static bool _cjose_jws_build_dig_sha(cjose_jws_t *jws, const cjose_jwk_t *jwk, c

if (NULL != jws->dig)
{
cjose_get_dealloc()(jws->dig);
jws->dig = NULL;
cjose_get_dealloc()(jws->dig);
jws->dig = NULL;
}

// allocate buffer for digest
Expand Down Expand Up @@ -264,6 +264,12 @@ static bool _cjose_jws_build_dig_hmac_sha(cjose_jws_t *jws, const cjose_jwk_t *j
goto _cjose_jws_build_dig_hmac_sha_cleanup;
}

if (NULL != jws->dig)
{
cjose_get_dealloc()(jws->dig);
jws->dig = NULL;
}

// allocate buffer for digest
jws->dig_len = EVP_MD_size(digest_alg);
jws->dig = (uint8_t *)cjose_get_alloc()(jws->dig_len);
Expand Down