]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.11] gh-115136: Fix possible NULL deref in getpath_joinpath() (GH-115137) (ПР-115158)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 8 Feb 2024 09:18:16 +0000 (10:18 +0100)
committerGitHub <noreply@github.com>
Thu, 8 Feb 2024 09:18:16 +0000 (11:18 +0200)
(cherry picked from commit 9e90313320a2af2d9ff7049ed3842344ed236630)

Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru>
Co-authored-by: Artem Chernyshev <62871052+dTenebrae@users.noreply.github.com>
Modules/getpath.c

index 2a14de0c915e9bf5d78ea21470e1a3591695a153..61d654065fdca0cf95b9aef787cce09f72da82fd 100644 (file)
@@ -265,6 +265,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;