Skip to content

Commit

Permalink
scratch_destroy: move VERIFY_CHECK after invalid scrach space check
Browse files Browse the repository at this point in the history
  • Loading branch information
siv2r authored and dderjoel committed May 23, 2023
1 parent 13754aa commit 78655c1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/scratch_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ static secp256k1_scratch* secp256k1_scratch_create(const secp256k1_callback* err

static void secp256k1_scratch_destroy(const secp256k1_callback* error_callback, secp256k1_scratch* scratch) {
if (scratch != NULL) {
VERIFY_CHECK(scratch->alloc_size == 0); /* all checkpoints should be applied */
if (secp256k1_memcmp_var(scratch->magic, "scratch", 8) != 0) {
secp256k1_callback_call(error_callback, "invalid scratch space");
return;
}
VERIFY_CHECK(scratch->alloc_size == 0); /* all checkpoints should be applied */
memset(scratch->magic, 0, sizeof(scratch->magic));
free(scratch);
}
Expand Down

0 comments on commit 78655c1

Please sign in to comment.