On first allocation, the PL_CRYPTO_HASH_CONTEXT was not properly zero'd (only some fields were explicitely set to NULL). This caused later code to think the mac context was there when it in fact wasn't.
The code that triggered this bug for me was in pl_crypto_hash_context_copy. This checks if the mac field is NULL. If not, it'll use the mac_ctx field.
Zeroing the whole struct will prevent bugs like this from cropping up in the future without having to explicitely remember to NULL-initialize new fields and such.
On first allocation, the
PL_CRYPTO_HASH_CONTEXT
was not properly zero'd (only some fields were explicitely set to NULL). This caused later code to think the mac context was there when it in fact wasn't.The code that triggered this bug for me was in
pl_crypto_hash_context_copy
. This checks if themac
field is NULL. If not, it'll use themac_ctx
field.Zeroing the whole struct will prevent bugs like this from cropping up in the future without having to explicitely remember to NULL-initialize new fields and such.
See also https://github.com/SWI-Prolog/swipl-devel/issues/1014.