Skip to content

Commit e96d943

Browse files
authored
Set default arguments in _testlimitedcapi/unicode.c (#159380)
Some optional arguments had no default value leading to undefined behavior if they were omitted.
1 parent 9f52b44 commit e96d943

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
@@ -993,7 +993,7 @@ unicode_encodecodepage(PyObject *self, PyObject *args)
993993
{
994994
int code_page;
995995
PyObject *unicode;
996-
const char *errors;
996+
const char *errors = NULL;
997997

998998
if (!PyArg_ParseTuple(args, "iO|z", &code_page, &unicode, &errors))
999999
return NULL;
@@ -1010,7 +1010,7 @@ unicode_decodelocaleandsize(PyObject *self, PyObject *args)
10101010
{
10111011
const char *data;
10121012
Py_ssize_t size;
1013-
const char *errors;
1013+
const char *errors = NULL;
10141014

10151015
if (!PyArg_ParseTuple(args, "y#|z", &data, &size, &errors))
10161016
return NULL;
@@ -1024,7 +1024,7 @@ unicode_decodelocale(PyObject *self, PyObject *args)
10241024
{
10251025
const char *data;
10261026
Py_ssize_t size;
1027-
const char *errors;
1027+
const char *errors = NULL;
10281028

10291029
if (!PyArg_ParseTuple(args, "y#|z", &data, &size, &errors))
10301030
return NULL;
@@ -1037,7 +1037,7 @@ static PyObject *
10371037
unicode_encodelocale(PyObject *self, PyObject *args)
10381038
{
10391039
PyObject *unicode;
1040-
const char *errors;
1040+
const char *errors = NULL;
10411041

10421042
if (!PyArg_ParseTuple(args, "O|z", &unicode, &errors))
10431043
return NULL;
@@ -1331,7 +1331,7 @@ unicode_comparewithasciistring(PyObject *self, PyObject *args)
13311331
{
13321332
PyObject *left;
13331333
const char *right = NULL;
1334-
Py_ssize_t right_len;
1334+
Py_ssize_t right_len = 0;
13351335
int result;
13361336

13371337
if (!PyArg_ParseTuple(args, "O|y#", &left, &right, &right_len))
@@ -1370,7 +1370,7 @@ unicode_equaltoutf8andsize(PyObject *self, PyObject *args)
13701370
{
13711371
PyObject *left;
13721372
const char *right = NULL;
1373-
Py_ssize_t right_len;
1373+
Py_ssize_t right_len = 0;
13741374
Py_ssize_t size = -100;
13751375
int result;
13761376

0 commit comments

Comments
 (0)