From 214ac166960f49da273438e22d37c8b32d995113 Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Thu, 8 Feb 2024 10:18:16 +0100 Subject: =?UTF-8?q?[3.11]=20gh-115136:=20Fix=20possible=20NULL=20deref=20i?= =?UTF-8?q?n=20getpath=5Fjoinpath()=20(GH-115137)=20(=D0=9F=D0=A0-115158)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 9e90313320a2af2d9ff7049ed3842344ed236630) Signed-off-by: Artem Chernyshev Co-authored-by: Artem Chernyshev <62871052+dTenebrae@users.noreply.github.com> --- Modules/getpath.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Modules/getpath.c b/Modules/getpath.c index 2a14de0..61d6540 100644 --- a/Modules/getpath.c +++ b/Modules/getpath.c @@ -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; -- cgit v0.12