diff --git a/src/jws.c b/src/jws.c index 4e03554..dbbdc1e 100644 --- a/src/jws.c +++ b/src/jws.c @@ -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 @@ -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);