From 9eab0039eae110a5a198827974f0e39ef37f619e Mon Sep 17 00:00:00 2001 From: Alex Henrie Date: Mon, 1 Mar 2021 19:50:04 -0700 Subject: [PATCH] bpo-43362: Fix bad free in py_sha3_new_impl function --- Modules/_sha3/sha3module.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/_sha3/sha3module.c b/Modules/_sha3/sha3module.c index cae10f99d5b8df..c31e8a270bdb9d 100644 --- a/Modules/_sha3/sha3module.c +++ b/Modules/_sha3/sha3module.c @@ -202,6 +202,7 @@ py_sha3_new_impl(PyTypeObject *type, PyObject *data, int usedforsecurity) assert(state != NULL); HashReturn res; + Py_buffer buf = {NULL, NULL}; if (type == state->sha3_224_type) { res = Keccak_HashInitialize_SHA3_224(&self->hash_state); } else if (type == state->sha3_256_type) { @@ -229,7 +230,6 @@ py_sha3_new_impl(PyTypeObject *type, PyObject *data, int usedforsecurity) goto error; } - Py_buffer buf = {NULL, NULL}; if (data) { GET_BUFFER_VIEW_OR_ERROR(data, &buf, goto error); if (buf.len >= HASHLIB_GIL_MINSIZE) {