From: Ivy Xu Date: Mon, 22 Jun 2026 13:59:22 +0000 (+0800) Subject: gh-151126: Fix missing `PyErr_NoMemory` in `getpath.c` (#151590) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4448205d95e87ca3d1e23cc350af59ec48b3321b;p=thirdparty%2FPython%2Fcpython.git gh-151126: Fix missing `PyErr_NoMemory` in `getpath.c` (#151590) --- diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-17-16-26-45.gh-issue-151126.Yc_6wC.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-17-16-26-45.gh-issue-151126.Yc_6wC.rst new file mode 100644 index 000000000000..29bb03d2d408 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-17-16-26-45.gh-issue-151126.Yc_6wC.rst @@ -0,0 +1,2 @@ +Avoid possible crash in ``getpath.c`` where a device has no memory left. Now +it properly raises a :exc:`MemoryError`. Patch by Ivy Xu. diff --git a/Modules/getpath.c b/Modules/getpath.c index 1e75993480ae..0c80678a678d 100644 --- a/Modules/getpath.c +++ b/Modules/getpath.c @@ -368,6 +368,7 @@ getpath_readlines(PyObject *Py_UNUSED(self), PyObject *args) if (!buffer) { Py_DECREF(r); fclose(fp); + PyErr_NoMemory(); return NULL; }