Skip to content

Commit 4045980

Browse files
committed
avoid overwrite exception in py_evp_fromname
1 parent f06a52e commit 4045980

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

Modules/_hashopenssl.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,9 @@ py_evp_fromname(PyObject *module, const char *digestname, PyObject *data_obj,
951951

952952
int result = EVP_DigestInit_ex(self->ctx, digest, NULL);
953953
if (!result) {
954-
goto error;
954+
(void)_setException(PyExc_ValueError, NULL);
955+
Py_CLEAR(self);
956+
goto exit;
955957
}
956958

957959
if (view.buf && view.len) {
@@ -965,7 +967,8 @@ py_evp_fromname(PyObject *module, const char *digestname, PyObject *data_obj,
965967
result = EVP_hash(self, view.buf, view.len);
966968
}
967969
if (result == -1) {
968-
goto error;
970+
Py_CLEAR(self);
971+
goto exit;
969972
}
970973
}
971974

@@ -976,11 +979,6 @@ py_evp_fromname(PyObject *module, const char *digestname, PyObject *data_obj,
976979
assert(digest != NULL);
977980
PY_EVP_MD_free(digest);
978981
return (PyObject *)self;
979-
980-
error:
981-
Py_CLEAR(self);
982-
_setException(PyExc_ValueError, NULL);
983-
goto exit;
984982
}
985983

986984

0 commit comments

Comments
 (0)