From: Artem Chernyshev <62871052+dTenebrae@users.noreply.github.com> Date: Thu, 8 Feb 2024 08:40:38 +0000 (+0300) Subject: gh-115136: Fix possible NULL deref in getpath_joinpath() (GH-115137) X-Git-Tag: v3.13.0a4~115 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9e90313320a2af2d9ff7049ed3842344ed236630;p=thirdparty%2FPython%2Fcpython.git gh-115136: Fix possible NULL deref in getpath_joinpath() (GH-115137) Signed-off-by: Artem Chernyshev --- diff --git a/Modules/getpath.c b/Modules/getpath.c index a3c8fc269d1c..abed13902824 100644 --- a/Modules/getpath.c +++ b/Modules/getpath.c @@ -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;