Skip to content

Commit 9e90313

Browse files
authored
gh-115136: Fix possible NULL deref in getpath_joinpath() (GH-115137)
Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru>
1 parent 4a7f638 commit 9e90313

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
@@ -262,6 +262,10 @@ getpath_joinpath(PyObject *Py_UNUSED(self), PyObject *args)
262262
}
263263
/* Convert all parts to wchar and accumulate max final length */
264264
wchar_t **parts = (wchar_t **)PyMem_Malloc(n * sizeof(wchar_t *));
265+
if (parts == NULL) {
266+
PyErr_NoMemory();
267+
return NULL;
268+
}
265269
memset(parts, 0, n * sizeof(wchar_t *));
266270
Py_ssize_t cchFinal = 0;
267271
Py_ssize_t first = 0;

0 commit comments

Comments
 (0)