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)
2847
2847
static int
2848
2848
_PySys_AddWarnOptionWithError (PyThreadState * tstate , PyObject * option )
2849
2849
{
2850
+ assert (tstate != NULL );
2850
2851
PyObject * warnoptions = get_warnoptions (tstate );
2851
2852
if (warnoptions == NULL ) {
2852
2853
return -1 ;
@@ -2862,11 +2863,11 @@ PyAPI_FUNC(void)
2862
2863
PySys_AddWarnOptionUnicode (PyObject * option )
2863
2864
{
2864
2865
PyThreadState * tstate = _PyThreadState_GET ();
2866
+ _Py_EnsureTstateNotNULL (tstate );
2867
+ assert (!_PyErr_Occurred (tstate ));
2865
2868
if (_PySys_AddWarnOptionWithError (tstate , option ) < 0 ) {
2866
2869
/* No return value, therefore clear error state if possible */
2867
- if (tstate ) {
2868
- _PyErr_Clear (tstate );
2869
- }
2870
+ _PyErr_Clear (tstate );
2870
2871
}
2871
2872
}
2872
2873
You can’t perform that action at this time.
0 commit comments