From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Thu, 8 Feb 2024 09:18:38 +0000 (+0100) Subject: [3.12] gh-115136: Fix possible NULL deref in getpath_joinpath() (GH-115137) (GH-115157) X-Git-Tag: v3.12.3~320 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=dc01c84ed066ec19704f018d3925dc2fe812a2a8;p=thirdparty%2FPython%2Fcpython.git [3.12] gh-115136: Fix possible NULL deref in getpath_joinpath() (GH-115137) (GH-115157) (cherry picked from commit 9e90313320a2af2d9ff7049ed3842344ed236630) Signed-off-by: Artem Chernyshev Co-authored-by: Artem Chernyshev <62871052+dTenebrae@users.noreply.github.com> --- diff --git a/Modules/getpath.c b/Modules/getpath.c index b9914a0c8e9d..0a3100007511 100644 --- a/Modules/getpath.c +++ b/Modules/getpath.c @@ -259,6 +259,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;