Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfad36bf

Browse files
gh-126108: Fix potential null pointer dereference inPySys_AddWarnOptionUnicode (#126118)
1 parent7eaef74 commitfad36bf

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a possible ``NULL`` pointer dereference in:c:func:`!PySys_AddWarnOptionUnicode`.

‎Python/sysmodule.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2847,6 +2847,7 @@ PySys_ResetWarnOptions(void)
28472847
staticint
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)
28622863
PySys_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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp