Closed
Description
Bug report
Bug description:
Pointer tstate is compared to a NULL value here, but above there is a dereference. Stack trace: _PySys_AddWarnOptionWithError -> get_warnoptions -> _PySys_GetAttr. Correct code should look like this:
void
PySys_AddWarnOptionUnicode(PyObject *option)
{
PyThreadState *tstate = _PyThreadState_GET();
if (tstate && _PySys_AddWarnOptionWithError(tstate, option) < 0) {
/* No return value, therefore clear error state if possible */
_PyErr_Clear(tstate);
}
}
CPython versions tested on:
3.11
Operating systems tested on:
No response
Linked PRs
- gh-126108: Fix potential null pointer dereference in PySys_AddWarnOptionUnicode #126118
- [3.13] gh-126108: Fix potential null pointer dereference in
PySys_AddWarnOptionUnicode
(GH-126118) #129520 - [3.12] gh-126108: Fix potential null pointer dereference in
PySys_AddWarnOptionUnicode
(GH-126118) #129522