gh-126108: Fix potential null pointer dereference in PySys_AddWarnOptionUnicode
(#126118)
This commit is contained in:
parent
7eaef74561
commit
fad36bf382
@ -0,0 +1 @@
|
||||
Fix a possible ``NULL`` pointer dereference in :c:func:`!PySys_AddWarnOptionUnicode`.
|
@ -2847,6 +2847,7 @@ PySys_ResetWarnOptions(void)
|
||||
static int
|
||||
_PySys_AddWarnOptionWithError(PyThreadState *tstate, PyObject *option)
|
||||
{
|
||||
assert(tstate != NULL);
|
||||
PyObject *warnoptions = get_warnoptions(tstate);
|
||||
if (warnoptions == NULL) {
|
||||
return -1;
|
||||
@ -2862,11 +2863,11 @@ PyAPI_FUNC(void)
|
||||
PySys_AddWarnOptionUnicode(PyObject *option)
|
||||
{
|
||||
PyThreadState *tstate = _PyThreadState_GET();
|
||||
_Py_EnsureTstateNotNULL(tstate);
|
||||
assert(!_PyErr_Occurred(tstate));
|
||||
if (_PySys_AddWarnOptionWithError(tstate, option) < 0) {
|
||||
/* No return value, therefore clear error state if possible */
|
||||
if (tstate) {
|
||||
_PyErr_Clear(tstate);
|
||||
}
|
||||
_PyErr_Clear(tstate);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user