Skip to content

Commit f885523

Browse files
committed
fix
1 parent f67f251 commit f885523

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Python/crossinterp.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1805,6 +1805,15 @@ _PyXI_InitFailureUTF8(_PyXI_failure *failure,
18051805
int
18061806
_PyXI_InitFailure(_PyXI_failure *failure, _PyXI_errcode code, PyObject *obj)
18071807
{
1808+
if (obj == NULL) {
1809+
*failure = (_PyXI_failure){
1810+
.code = code,
1811+
.msg = NULL,
1812+
.msg_owned = 0,
1813+
};
1814+
return 0;
1815+
}
1816+
18081817
PyObject *msgobj = PyObject_Str(obj);
18091818
if (msgobj == NULL) {
18101819
return -1;
@@ -1813,8 +1822,7 @@ _PyXI_InitFailure(_PyXI_failure *failure, _PyXI_errcode code, PyObject *obj)
18131822
// That happens automatically in _capture_current_exception().
18141823
const char *msg = _copy_string_obj_raw(msgobj, NULL);
18151824
Py_DECREF(msgobj);
1816-
if (PyErr_Occurred()) {
1817-
PyMem_RawFree((void *)msg);
1825+
if (msg == NULL) {
18181826
return -1;
18191827
}
18201828
*failure = (_PyXI_failure){

0 commit comments

Comments
 (0)