]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.15] gh-151763: Fix NULL dereference in `os._path_normpath()` under OOM (GH-151779...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 24 Jun 2026 16:25:28 +0000 (18:25 +0200)
committerGitHub <noreply@github.com>
Wed, 24 Jun 2026 16:25:28 +0000 (16:25 +0000)
(cherry picked from commit ce8b81fff4094bd0cfb0c57193135bfc904c0ca2)

Co-authored-by: Zain Nadeem <zainnadeemzainnadeem80@gmail.com>
Modules/posixmodule.c

index b58b2af3c5f887d2110aeb1490c9db5148db47b3..ce8b6d3ff4c68920448d825f9f450823e1b86a96 100644 (file)
@@ -6145,6 +6145,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));
     }