diff options
author | Tim Peters <tim.peters@gmail.com> | 2001-10-27 03:58:40 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2001-10-27 03:58:40 (GMT) |
commit | 45772cde7e6d936cb37a4762eba3ca23c0b1c667 (patch) | |
tree | d808640b773682c0ac4367fc69e6b977f1f79844 /Python/getargs.c | |
parent | a9f4739a1b315417d5b79055a64ee8dd11d1b173 (diff) | |
download | cpython-45772cde7e6d936cb37a4762eba3ca23c0b1c667.zip cpython-45772cde7e6d936cb37a4762eba3ca23c0b1c667.tar.gz cpython-45772cde7e6d936cb37a4762eba3ca23c0b1c667.tar.bz2 |
PyArg_ParseTupleAndKeywords: do basic sanity checks on the arguments,
and raise an error if they're insane.
vgetargskeywords: the same, except that since this is an internal routine,
just assert that the arguments are sane.
Diffstat (limited to 'Python/getargs.c')
-rw-r--r-- | Python/getargs.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/Python/getargs.c b/Python/getargs.c index 451b914..840bf51 100644 --- a/Python/getargs.c +++ b/Python/getargs.c @@ -1005,7 +1005,16 @@ PyArg_ParseTupleAndKeywords(PyObject *args, { int retval; va_list va; - + + if ((args == NULL || !PyTuple_Check(args)) || + (keywords != NULL && !PyDict_Check(keywords)) || + format == NULL || + kwlist == NULL) + { + PyErr_BadInternalCall(); + return -1; + } + va_start(va, kwlist); retval = vgetargskeywords(args, keywords, format, kwlist, &va); va_end(va); @@ -1029,6 +1038,12 @@ vgetargskeywords(PyObject *args, PyObject *keywords, char *format, int nkwds, pos, match, converted; PyObject *key, *value; + assert(args != NULL && PyTuple_Check(args)); + assert(keywords == NULL || PyDict_Check(keywords)); + assert(format != NULL); + assert(kwlist != NULL); + assert(p_va != NULL); + /* nested tuples cannot be parsed when using keyword arguments */ for (;;) { |