]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-151763: Fix NULL dereference in `os._path_normpath()` under OOM (#151779)
authorZain Nadeem <zainnadeemzainnadeem80@gmail.com>
Wed, 24 Jun 2026 15:56:10 +0000 (20:56 +0500)
committerGitHub <noreply@github.com>
Wed, 24 Jun 2026 15:56:10 +0000 (16:56 +0100)
Modules/posixmodule.c

index 1f1b7fa729c01c8e0ab227a6fb24ca709ca3af8d..c52d2e7d5bfbd9f54e8fdf4859a9ae6e474db146 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));
     }