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 @@ -2841,6 +2841,7 @@ PySys_ResetWarnOptions(void)
2841
2841
static int
2842
2842
_PySys_AddWarnOptionWithError (PyThreadState * tstate , PyObject * option )
2843
2843
{
2844
+ assert (tstate != NULL );
2844
2845
PyObject * warnoptions = get_warnoptions (tstate );
2845
2846
if (warnoptions == NULL ) {
2846
2847
return -1 ;
@@ -2856,11 +2857,11 @@ PyAPI_FUNC(void)
2856
2857
PySys_AddWarnOptionUnicode (PyObject * option )
2857
2858
{
2858
2859
PyThreadState * tstate = _PyThreadState_GET ();
2860
+ _Py_EnsureTstateNotNULL (tstate );
2861
+ assert (!_PyErr_Occurred (tstate ));
2859
2862
if (_PySys_AddWarnOptionWithError (tstate , option ) < 0 ) {
2860
2863
/* No return value, therefore clear error state if possible */
2861
- if (tstate ) {
2862
- _PyErr_Clear (tstate );
2863
- }
2864
+ _PyErr_Clear (tstate );
2864
2865
}
2865
2866
}
2866
2867
You can’t perform that action at this time.
0 commit comments