diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2024-02-08 09:18:38 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-08 09:18:38 (GMT) |
commit | dc01c84ed066ec19704f018d3925dc2fe812a2a8 (patch) | |
tree | 8b26739e0664044e7765ba798426aaf98f138ddf /Modules/getpath.c | |
parent | 2016fbd682b9158beff67ebb74a8413dfa6fdf5d (diff) | |
download | cpython-dc01c84ed066ec19704f018d3925dc2fe812a2a8.zip cpython-dc01c84ed066ec19704f018d3925dc2fe812a2a8.tar.gz cpython-dc01c84ed066ec19704f018d3925dc2fe812a2a8.tar.bz2 |
[3.12] gh-115136: Fix possible NULL deref in getpath_joinpath() (GH-115137) (GH-115157)
(cherry picked from commit 9e90313320a2af2d9ff7049ed3842344ed236630)
Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru>
Co-authored-by: Artem Chernyshev <62871052+dTenebrae@users.noreply.github.com>
Diffstat (limited to 'Modules/getpath.c')
-rw-r--r-- | Modules/getpath.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Modules/getpath.c b/Modules/getpath.c index b9914a0..0a31000 100644 --- a/Modules/getpath.c +++ b/Modules/getpath.c @@ -259,6 +259,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; |