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 @@ -2847,6 +2847,7 @@ PySys_ResetWarnOptions(void)
28472847static int
28482848_PySys_AddWarnOptionWithError (PyThreadState * tstate , PyObject * option )
28492849{
2850+ assert (tstate != NULL );
28502851 PyObject * warnoptions = get_warnoptions (tstate );
28512852 if (warnoptions == NULL ) {
28522853 return -1 ;
@@ -2862,11 +2863,11 @@ PyAPI_FUNC(void)
28622863PySys_AddWarnOptionUnicode (PyObject * option )
28632864{
28642865 PyThreadState * tstate = _PyThreadState_GET ();
2866+ _Py_EnsureTstateNotNULL (tstate );
2867+ assert (!_PyErr_Occurred (tstate ));
28652868 if (_PySys_AddWarnOptionWithError (tstate , option ) < 0 ) {
28662869 /* No return value, therefore clear error state if possible */
2867- if (tstate ) {
2868- _PyErr_Clear (tstate );
2869- }
2870+ _PyErr_Clear (tstate );
28702871 }
28712872}
28722873
You can’t perform that action at this time.
0 commit comments