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.
5 changes: 4 additions & 1 deletion Modules/blake2module.c
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,10 @@ blake2_blake2b_copy_unlocked(Blake2Object *self, Blake2Object *cpy)
} \
} 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:
Expand All @@ -778,7 +782,6 @@ blake2_blake2b_copy_unlocked(Blake2Object *self, Blake2Object *cpy)
Py_UNREACHABLE();
}
#undef BLAKE2_COPY
cpy->impl = self->impl;
return 0;

error:
Expand Down
Loading