diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2022-07-18 15:07:31 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-18 15:07:31 (GMT) |
commit | 067f0da33506f70c36a67d5f3d8d011c8dae10c9 (patch) | |
tree | c6cf952e26949902479d7729af9da92acdf0ba38 /Modules | |
parent | 2f8bff6879c5d76d143068e8bc867196a7d28afc (diff) | |
download | cpython-067f0da33506f70c36a67d5f3d8d011c8dae10c9.zip cpython-067f0da33506f70c36a67d5f3d8d011c8dae10c9.tar.gz cpython-067f0da33506f70c36a67d5f3d8d011c8dae10c9.tar.bz2 |
gh-94930: skipitem() in getargs.c should return non-NULL on error (GH-94931)
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_testcapimodule.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 436c701..6b9afe2 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -6035,6 +6035,7 @@ test_macros(PyObject *self, PyObject *Py_UNUSED(args)) static PyObject *negative_dictoffset(PyObject *, PyObject *); static PyObject *test_buildvalue_issue38913(PyObject *, PyObject *); static PyObject *getargs_s_hash_int(PyObject *, PyObject *, PyObject*); +static PyObject *getargs_s_hash_int2(PyObject *, PyObject *, PyObject*); static PyMethodDef TestMethods[] = { {"raise_exception", raise_exception, METH_VARARGS}, @@ -6157,6 +6158,8 @@ static PyMethodDef TestMethods[] = { {"getargs_s_hash", getargs_s_hash, METH_VARARGS}, {"getargs_s_hash_int", _PyCFunction_CAST(getargs_s_hash_int), METH_VARARGS|METH_KEYWORDS}, + {"getargs_s_hash_int2", _PyCFunction_CAST(getargs_s_hash_int2), + METH_VARARGS|METH_KEYWORDS}, {"getargs_z", getargs_z, METH_VARARGS}, {"getargs_z_star", getargs_z_star, METH_VARARGS}, {"getargs_z_hash", getargs_z_hash, METH_VARARGS}, @@ -7794,11 +7797,27 @@ PyAPI_FUNC(int) PyArg_ParseTupleAndKeywords(PyObject *, PyObject *, static PyObject * getargs_s_hash_int(PyObject *self, PyObject *args, PyObject *kwargs) { - static char *keywords[] = {"", "x", NULL}; + static char *keywords[] = {"", "", "x", NULL}; + Py_buffer buf = {NULL}; + const char *s; + int len; + int i = 0; + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "w*|s#i", keywords, &buf, &s, &len, &i)) + return NULL; + PyBuffer_Release(&buf); + Py_RETURN_NONE; +} + +static PyObject * +getargs_s_hash_int2(PyObject *self, PyObject *args, PyObject *kwargs) +{ + static char *keywords[] = {"", "", "x", NULL}; + Py_buffer buf = {NULL}; const char *s; int len; int i = 0; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|s#i", keywords, &s, &len, &i)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "w*|(s#)i", keywords, &buf, &s, &len, &i)) return NULL; + PyBuffer_Release(&buf); Py_RETURN_NONE; } |