https://github.com/python/cpython/commit/58476e8cbbe19fb60b5819d30d0020bd790fad30
commit: 58476e8cbbe19fb60b5819d30d0020bd790fad30
branch: 3.13
author: Miss Islington (bot) <[email protected]>
committer: StanFromIreland <[email protected]>
date: 2026-06-24T16:22:23Z
summary:

[3.13] gh-151763: Fix NULL dereference in `os._path_normpath()` under OOM 
(GH-151779) (#152094)

(cherry picked from commit ce8b81fff4094bd0cfb0c57193135bfc904c0ca2)

Co-authored-by: Zain Nadeem <[email protected]>

files:
M Modules/posixmodule.c

diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 3fcf19e63c19ae..a633c5f869376f 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -5577,6 +5577,9 @@ os__path_normpath_impl(PyObject *module, path_t *path)
     else {
         result = PyUnicode_FromWideChar(norm_path, norm_len);
     }
+    if (result == NULL) {
+        return NULL;
+    }
     if (PyBytes_Check(path->object)) {
         Py_SETREF(result, PyUnicode_EncodeFSDefault(result));
     }

_______________________________________________
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