--- /dev/null
+Prevent a crash when allocation fails while copying a :func:`BLAKE-2s/2b
+<hashlib.blake2b>` object. Patch by Bénédikt Tran.
blake2_blake2b_copy_locked(Blake2Object *self, Blake2Object *cpy)
{
assert(cpy != NULL);
+
+ // Ensure that the implementation type is consistent with the HACL* state.
+ // See https://github.com/python/cpython/issues/152851 for details.
+ cpy->impl = self->impl;
+
switch (self->impl) {
#if _Py_HACL_CAN_COMPILE_VEC256
case Blake2b_256: {
default:
Py_UNREACHABLE();
}
- cpy->impl = self->impl;
return 0;
error: