gh-97758: Fix a crash in getpath_joinpath() called without arguments (GH-97759)

(cherry picked from commit f8cbd79d32)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
Miss Islington (bot) 2022-10-05 03:20:32 -07:00 committed by GitHub
parent 79b5c1ad3c
commit 73e3510bdb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -261,7 +261,7 @@ getpath_joinpath(PyObject *Py_UNUSED(self), PyObject *args)
}
Py_ssize_t n = PyTuple_GET_SIZE(args);
if (n == 0) {
return PyUnicode_FromString(NULL);
return PyUnicode_FromStringAndSize(NULL, 0);
}
/* Convert all parts to wchar and accumulate max final length */
wchar_t **parts = (wchar_t **)PyMem_Malloc(n * sizeof(wchar_t *));