Skip to content

Commit dc01c84

Browse files
[3.12] gh-115136: Fix possible NULL deref in getpath_joinpath() (GH-115137) (GH-115157)
(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 2016fbd commit dc01c84

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
@@ -259,6 +259,10 @@ getpath_joinpath(PyObject *Py_UNUSED(self), PyObject *args)
259259
}
260260
/* Convert all parts to wchar and accumulate max final length */
261261
wchar_t **parts = (wchar_t **)PyMem_Malloc(n * sizeof(wchar_t *));
262+
if (parts == NULL) {
263+
PyErr_NoMemory();
264+
return NULL;
265+
}
262266
memset(parts, 0, n * sizeof(wchar_t *));
263267
Py_ssize_t cchFinal = 0;
264268
Py_ssize_t first = 0;

0 commit comments

Comments
 (0)