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

miss-islington webhook-mailer at python.org
Wed Oct 5 06:20:37 EDT 2022


https://github.com/python/cpython/commit/73e3510bdb2762e371e8545f1a4c68b821fcdcf2
commit: 73e3510bdb2762e371e8545f1a4c68b821fcdcf2
branch: 3.11
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2022-10-05T03:20:32-07:00
summary:

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

(cherry picked from commit f8cbd79d328d90443acabc41d246332c302c815a)

Co-authored-by: Serhiy Storchaka <storchaka at gmail.com>

files:
M Modules/getpath.c

diff --git a/Modules/getpath.c b/Modules/getpath.c
index be704adbde94..ceacf36d8968 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 *));



More information about the Python-checkins mailing list