gh-115136: Fix possible NULL deref in getpath_joinpath() (GH-115137)

Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru>
This commit is contained in:
Artem Chernyshev 2024-02-08 11:40:38 +03:00 committed by GitHub
parent 4a7f63869a
commit 9e90313320
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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;