File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed
Misc/NEWS.d/next/Security Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change 1+ Fix a possible ``NULL `` pointer dereference in :c:func: `!PySys_AddWarnOptionUnicode `.
Original file line number Diff line number Diff line change @@ -2653,6 +2653,7 @@ PySys_ResetWarnOptions(void)
26532653static int
26542654_PySys_AddWarnOptionWithError (PyThreadState * tstate , PyObject * option )
26552655{
2656+ assert (tstate != NULL );
26562657 PyObject * warnoptions = get_warnoptions (tstate );
26572658 if (warnoptions == NULL ) {
26582659 return -1 ;
@@ -2667,11 +2668,11 @@ void
26672668PySys_AddWarnOptionUnicode (PyObject * option )
26682669{
26692670 PyThreadState * tstate = _PyThreadState_GET ();
2671+ _Py_EnsureTstateNotNULL (tstate );
2672+ assert (!_PyErr_Occurred (tstate ));
26702673 if (_PySys_AddWarnOptionWithError (tstate , option ) < 0 ) {
26712674 /* No return value, therefore clear error state if possible */
2672- if (tstate ) {
2673- _PyErr_Clear (tstate );
2674- }
2675+ _PyErr_Clear (tstate );
26752676 }
26762677}
26772678
You can’t perform that action at this time.
0 commit comments