Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed a use-after-free in _ensure_notshareableerror and an exception leak in _PyXI_UnwrapNotShareableError and a use-after-free in _get_xidata within the cross-interpreter data subsystem.
6 changes: 3 additions & 3 deletions Python/crossinterp.c
Original file line number Diff line number Diff line change
Expand Up @@ -491,24 +491,24 @@ _get_xidata(PyThreadState *tstate,
Py_DECREF(obj);
return -1;
}
// Fall back to obj
Py_DECREF(obj);
if (!_PyErr_Occurred(tstate)) {
_set_xid_lookup_failure(tstate, obj, NULL, NULL);
}
Py_DECREF(obj);
return -1;
}
int res = getdata.basic != NULL
? getdata.basic(tstate, obj, xidata)
: getdata.fallback(tstate, obj, fallback, xidata);
Py_DECREF(obj);
if (res != 0) {
PyObject *cause = _PyErr_GetRaisedException(tstate);
assert(cause != NULL);
_set_xid_lookup_failure(tstate, obj, NULL, cause);
Py_XDECREF(cause);
Py_DECREF(obj);
return -1;
}
Py_DECREF(obj);

// Fill in the blanks and validate the result.
_PyXIData_INTERPID(xidata) = PyInterpreterState_GetID(interp);
Expand Down
1 change: 1 addition & 0 deletions Python/crossinterp_data_lookup.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ _PyXI_UnwrapNotShareableError(PyThreadState * tstate, _PyXI_failure *failure)
if (failure != NULL) {
_PyXI_errcode code = _PyXI_ERR_NOT_SHAREABLE;
if (_PyXI_InitFailure(failure, code, exc) < 0) {
_PyErr_SetRaisedException(tstate, exc);
return -1;
}
}
Expand Down
1 change: 1 addition & 0 deletions Python/crossinterp_exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ _ensure_notshareableerror(PyThreadState *tstate,
// A NotShareableError instance is already set.
assert(cause == NULL);
_PyErr_SetRaisedException(tstate, ctx);
return;
}
}
else {
Expand Down
Loading