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

This commit is contained in:
Serhiy Storchaka 2022-10-05 12:51:58 +03:00 committed by GitHub
parent e3ef400be7
commit f8cbd79d32
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 *));