https://github.com/python/cpython/commit/7fe3ddc8b949b81ae3b6180dea7762ab8c914b22
commit: 7fe3ddc8b949b81ae3b6180dea7762ab8c914b22
branch: 3.14
author: Miss Islington (bot) <[email protected]>
committer: sobolevn <[email protected]>
date: 2026-06-11T16:49:57Z
summary:

[3.14] gh-151126: Fix missing memory error in `os._path_splitroot` (GH-151339) 
(#151361)

gh-151126: Fix missing memory error in `os._path_splitroot` (GH-151339)
(cherry picked from commit 10595b1cb7ac04ba9a3ef3f7da4fa31c9966300d)

Co-authored-by: sobolevn <[email protected]>

files:
A Misc/NEWS.d/next/Library/2026-06-11-16-25-38.gh-issue-151126.bh_Usy.rst
M Modules/posixmodule.c

diff --git 
a/Misc/NEWS.d/next/Library/2026-06-11-16-25-38.gh-issue-151126.bh_Usy.rst 
b/Misc/NEWS.d/next/Library/2026-06-11-16-25-38.gh-issue-151126.bh_Usy.rst
new file mode 100644
index 00000000000000..25149057aa7d09
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2026-06-11-16-25-38.gh-issue-151126.bh_Usy.rst
@@ -0,0 +1,2 @@
+Fix a crash when :exc:`MemoryError` in :func:`!os._path_splitroot`
+was not set properly.
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 69e28a1ff95247..4ead98f49ac764 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -5240,7 +5240,7 @@ os__path_splitroot_impl(PyObject *module, path_t *path)
 
     buffer = (wchar_t*)PyMem_Malloc(sizeof(wchar_t) * (wcslen(path->wide) + 
1));
     if (!buffer) {
-        return NULL;
+        return PyErr_NoMemory();
     }
     wcscpy(buffer, path->wide);
     for (wchar_t *p = wcschr(buffer, L'/'); p; p = wcschr(p, L'/')) {

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to