gh-152851: fix a crash when copying a BLAKE-2s/2b object (GH-153008)
(cherry picked from commit
5a400ceafbbd4456ac65fbdbcf5d62ce9e8e4f9f)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
--- /dev/null
+Prevent a crash when allocation fails while copying a :func:`BLAKE-2s/2b
+<hashlib.blake2b>` object. Patch by Bénédikt Tran.
} \
} while (0)
+ // 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:
Py_UNREACHABLE();
}
#undef BLAKE2_COPY
- cpy->impl = self->impl;
return 0;
error: