From 41a73a47dd9ca16e2691fdd38167b91032e441d5 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Mon, 3 Oct 2022 14:43:53 +0300 Subject: [PATCH] gh-97758: Fix a crash in getpath_joinpath() called without arguments --- Modules/getpath.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/getpath.c b/Modules/getpath.c index be704adbde9468..ceacf36d8968a1 100644 --- a/Modules/getpath.c +++ b/Modules/getpath.c @@ -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 *));