Skip to content

Commit 77baa67

Browse files
committed
revert some constructor changes
1 parent ea033a3 commit 77baa67

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

Modules/md5module.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -312,20 +312,30 @@ _md5_md5_impl(PyObject *module, PyObject *data, int usedforsecurity,
312312
}
313313

314314
MD5object *new;
315+
Py_buffer buf;
316+
317+
if (string) {
318+
GET_BUFFER_VIEW_OR_ERROUT(string, &buf);
319+
}
320+
315321
MD5State *st = md5_get_state(module);
316322
if ((new = newMD5object(st)) == NULL) {
323+
if (string) {
324+
PyBuffer_Release(&buf);
325+
}
317326
return NULL;
318327
}
319328

320329
new->hash_state = Hacl_Hash_MD5_malloc();
321330
if (new->hash_state == NULL) {
322331
Py_DECREF(new);
332+
if (string) {
333+
PyBuffer_Release(&buf);
334+
}
323335
return PyErr_NoMemory();
324336
}
325337

326338
if (string) {
327-
Py_buffer buf;
328-
GET_BUFFER_VIEW_OR_ERROR(string, &buf, goto error);
329339
if (buf.len >= HASHLIB_GIL_MINSIZE) {
330340
/* Do not use self->mutex here as this is the constructor
331341
* where it is not yet possible to have concurrent access. */
@@ -340,10 +350,6 @@ _md5_md5_impl(PyObject *module, PyObject *data, int usedforsecurity,
340350
}
341351

342352
return (PyObject *)new;
343-
344-
error:
345-
Py_XDECREF(new);
346-
return NULL;
347353
}
348354

349355

0 commit comments

Comments
 (0)