diff options
author | Georg Brandl <georg@python.org> | 2006-07-26 08:03:10 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2006-07-26 08:03:10 (GMT) |
commit | 5f135787ec4040bfbeb16f2944086028635151db (patch) | |
tree | a7db166102d100e0d6e77fca48573772b88fb8ce /Modules/_testcapimodule.c | |
parent | 0619a329e822641dff088d9141a7885da882369c (diff) | |
download | cpython-5f135787ec4040bfbeb16f2944086028635151db.zip cpython-5f135787ec4040bfbeb16f2944086028635151db.tar.gz cpython-5f135787ec4040bfbeb16f2944086028635151db.tar.bz2 |
Part of bug #1523610: fix miscalculation of buffer length.
Also add a guard against NULL in converttuple and add a test case
(that previously would have crashed).
Diffstat (limited to 'Modules/_testcapimodule.c')
-rw-r--r-- | Modules/_testcapimodule.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 6b9dffd..b90ca57 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -294,6 +294,16 @@ test_L_code(PyObject *self) #endif /* ifdef HAVE_LONG_LONG */ +/* Test tuple argument processing */ +static PyObject * +getargs_tuple(PyObject *self, PyObject *args) +{ + int a, b, c; + if (!PyArg_ParseTuple(args, "i(ii)", &a, &b, &c)) + return NULL; + return Py_BuildValue("iii", a, b, c); +} + /* Functions to call PyArg_ParseTuple with integer format codes, and return the result. */ @@ -707,6 +717,7 @@ static PyMethodDef TestMethods[] = { {"test_null_strings", (PyCFunction)test_null_strings, METH_NOARGS}, {"test_string_from_format", (PyCFunction)test_string_from_format, METH_NOARGS}, + {"getargs_tuple", getargs_tuple, METH_VARARGS}, {"getargs_b", getargs_b, METH_VARARGS}, {"getargs_B", getargs_B, METH_VARARGS}, {"getargs_H", getargs_H, METH_VARARGS}, |