]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-115136: Fix possible NULL deref in getpath_joinpath() (GH-115137)
authorArtem Chernyshev <62871052+dTenebrae@users.noreply.github.com>
Thu, 8 Feb 2024 08:40:38 +0000 (11:40 +0300)
committerGitHub <noreply@github.com>
Thu, 8 Feb 2024 08:40:38 +0000 (08:40 +0000)
Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru>
Modules/getpath.c

index a3c8fc269d1c3cf6d3910d19bc128230d514671d..abed139028244ad7a8f5ef96790f1a737ec2d83c 100644 (file)
@@ -262,6 +262,10 @@ getpath_joinpath(PyObject *Py_UNUSED(self), PyObject *args)
     }
     /* Convert all parts to wchar and accumulate max final length */
     wchar_t **parts = (wchar_t **)PyMem_Malloc(n * sizeof(wchar_t *));
+    if (parts == NULL) {
+        PyErr_NoMemory();
+        return NULL;
+    }
     memset(parts, 0, n * sizeof(wchar_t *));
     Py_ssize_t cchFinal = 0;
     Py_ssize_t first = 0;