Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Prevent a crash when allocation fails while copying a :func:`BLAKE-2s/2b
<hashlib.blake2b>` object. Patch by Bénédikt Tran.
6 changes: 5 additions & 1 deletion Modules/blake2module.c
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,11 @@ static int
blake2_blake2b_copy_locked(Blake2Object *self, Blake2Object *cpy)
{
assert(cpy != NULL);

// Ensure that the implementation type is consistent with the HACL* state.
Comment thread
picnixz marked this conversation as resolved.
// See https://github.com/python/cpython/issues/152851 for details.
cpy->impl = self->impl;
Comment thread
picnixz marked this conversation as resolved.

switch (self->impl) {
#if _Py_HACL_CAN_COMPILE_VEC256
case Blake2b_256: {
Expand Down Expand Up @@ -768,7 +773,6 @@ blake2_blake2b_copy_locked(Blake2Object *self, Blake2Object *cpy)
default:
Py_UNREACHABLE();
}
cpy->impl = self->impl;
return 0;

error:
Expand Down
Loading