]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-151126: Fix missing `PyErr_NoMemory` in `getpath.c` (#151590)
authorIvy Xu <fakeshadow1337@gmail.com>
Mon, 22 Jun 2026 13:59:22 +0000 (21:59 +0800)
committerGitHub <noreply@github.com>
Mon, 22 Jun 2026 13:59:22 +0000 (14:59 +0100)
Misc/NEWS.d/next/Core_and_Builtins/2026-06-17-16-26-45.gh-issue-151126.Yc_6wC.rst [new file with mode: 0644]
Modules/getpath.c

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 (file)
index 0000000..29bb03d
--- /dev/null
@@ -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.
index 1e75993480ae363b99bb0f7b3e41866c237f647e..0c80678a678dc8bc3ea0da083625a98a3b3e6f9a 100644 (file)
@@ -368,6 +368,7 @@ getpath_readlines(PyObject *Py_UNUSED(self), PyObject *args)
     if (!buffer) {
         Py_DECREF(r);
         fclose(fp);
+        PyErr_NoMemory();
         return NULL;
     }