Skip to content

Commit 214ac16

Browse files
[3.11] gh-115136: Fix possible NULL deref in getpath_joinpath() (GH-115137) (ПР-115158)
(cherry picked from commit 9e90313) Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru> Co-authored-by: Artem Chernyshev <62871052+dTenebrae@users.noreply.github.com>
1 parent 5e686df commit 214ac16

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Modules/getpath.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,10 @@ getpath_joinpath(PyObject *Py_UNUSED(self), PyObject *args)
265265
}
266266
/* Convert all parts to wchar and accumulate max final length */
267267
wchar_t **parts = (wchar_t **)PyMem_Malloc(n * sizeof(wchar_t *));
268+
if (parts == NULL) {
269+
PyErr_NoMemory();
270+
return NULL;
271+
}
268272
memset(parts, 0, n * sizeof(wchar_t *));
269273
Py_ssize_t cchFinal = 0;
270274
Py_ssize_t first = 0;

0 commit comments

Comments
 (0)