Merge bitcoin-core/secp256k1#1114: _scratch_destroy: move VERIFY_CHECK after invalid scrach space check

1827c9bf2b7d4bf6a78c2f387bdb3e885a71e292 scratch_destroy: move VERIFY_CHECK after invalid scrach space check (siv2r)

Pull request description:

ACKs for top commit:
  sipa:
    utACK 1827c9bf2b7d4bf6a78c2f387bdb3e885a71e292
  jonasnick:
    ACK 1827c9bf2b7d4bf6a78c2f387bdb3e885a71e292

Tree-SHA512: 5c4f97ca16f46380b30d1d077a54e25eab21efb10e0ce3ca27e7f73a2318d130f0f0773e26b2fdfc8f9d98c1334880f9d80a51b0941be3ba0af2b656b7c0ea7e
This commit is contained in:
Jonas Nick 2022-06-29 19:30:58 +00:00
commit accadc94df
No known key found for this signature in database
GPG Key ID: 4861DBF262123605

View File

@ -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);
}