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

Commit68a8ca6

Browse files
gh-101819: Harden _io init (#104352)
Fix potential refleak if PyModule_AddObject() fails.
1 parent22f3425 commit68a8ca6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

‎Modules/_io/_iomodule.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -730,9 +730,11 @@ PyInit__io(void)
730730
"UnsupportedOperation",PyExc_OSError,PyExc_ValueError);
731731
if (state->unsupported_operation==NULL)
732732
gotofail;
733-
if (PyModule_AddObject(m,"UnsupportedOperation",
734-
Py_NewRef(state->unsupported_operation))<0)
733+
if (PyModule_AddObjectRef(m,"UnsupportedOperation",
734+
state->unsupported_operation)<0)
735+
{
735736
gotofail;
737+
}
736738

737739
/* BlockingIOError, for compatibility */
738740
if (PyModule_AddObjectRef(m,"BlockingIOError",
@@ -785,7 +787,6 @@ PyInit__io(void)
785787
returnm;
786788

787789
fail:
788-
Py_XDECREF(state->unsupported_operation);
789790
Py_DECREF(m);
790791
returnNULL;
791792
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp