Skip to content

Commit 43a8cdc

Browse files
[3.14] Set default arguments in _testlimitedcapi/unicode.c (GH-159380) (#159412)
Set default arguments in _testlimitedcapi/unicode.c (GH-159380) Some optional arguments had no default value leading to undefined behavior if they were omitted. (cherry picked from commit e96d943) Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent 0c42466 commit 43a8cdc

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

‎Modules/_testlimitedcapi/unicode.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ unicode_encodecodepage(PyObject *self, PyObject *args)
944944
{
945945
int code_page;
946946
PyObject *unicode;
947-
const char *errors;
947+
const char *errors = NULL;
948948

949949
if (!PyArg_ParseTuple(args, "iO|z", &code_page, &unicode, &errors))
950950
return NULL;
@@ -961,7 +961,7 @@ unicode_decodelocaleandsize(PyObject *self, PyObject *args)
961961
{
962962
const char *data;
963963
Py_ssize_t size;
964-
const char *errors;
964+
const char *errors = NULL;
965965

966966
if (!PyArg_ParseTuple(args, "y#|z", &data, &size, &errors))
967967
return NULL;
@@ -975,7 +975,7 @@ unicode_decodelocale(PyObject *self, PyObject *args)
975975
{
976976
const char *data;
977977
Py_ssize_t size;
978-
const char *errors;
978+
const char *errors = NULL;
979979

980980
if (!PyArg_ParseTuple(args, "y#|z", &data, &size, &errors))
981981
return NULL;
@@ -988,7 +988,7 @@ static PyObject *
988988
unicode_encodelocale(PyObject *self, PyObject *args)
989989
{
990990
PyObject *unicode;
991-
const char *errors;
991+
const char *errors = NULL;
992992

993993
if (!PyArg_ParseTuple(args, "O|z", &unicode, &errors))
994994
return NULL;
@@ -1282,7 +1282,7 @@ unicode_comparewithasciistring(PyObject *self, PyObject *args)
12821282
{
12831283
PyObject *left;
12841284
const char *right = NULL;
1285-
Py_ssize_t right_len;
1285+
Py_ssize_t right_len = 0;
12861286
int result;
12871287

12881288
if (!PyArg_ParseTuple(args, "O|y#", &left, &right, &right_len))
@@ -1321,7 +1321,7 @@ unicode_equaltoutf8andsize(PyObject *self, PyObject *args)
13211321
{
13221322
PyObject *left;
13231323
const char *right = NULL;
1324-
Py_ssize_t right_len;
1324+
Py_ssize_t right_len = 0;
13251325
Py_ssize_t size = -100;
13261326
int result;
13271327

0 commit comments

Comments
 (0)