summaryrefslogtreecommitdiffstats
path: root/Python/getargs.c
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-10-27 00:46:09 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-10-27 00:46:09 (GMT)
commita9f4739a1b315417d5b79055a64ee8dd11d1b173 (patch)
treebee52848ea3b622342d2bdc6f4741bc65c9f2e07 /Python/getargs.c
parentf4331c1c3874651cfa872c9dda8ab504e0129349 (diff)
downloadcpython-a9f4739a1b315417d5b79055a64ee8dd11d1b173.zip
cpython-a9f4739a1b315417d5b79055a64ee8dd11d1b173.tar.gz
cpython-a9f4739a1b315417d5b79055a64ee8dd11d1b173.tar.bz2
tuple(3,4,5,x=2) dumped core on my box. vgetargskeywords() overindexed
the kwlist vector whenever there was a mix of positional and keyword arguments, and the number of positional arguments exceeded the length of the kwlist vector. If there was just one more positional arg than keyword, the kwlist-terminating NULL got passed to PyMapping_HasKeyString, which set an internal error that vgetargskeywords() then squashed (but it's impossible to say whether it knew it was masking an error). If more than one more positional argument, it went on to pass random trash to PyMapping_HasKeyString, which is why the example at the start happened to kill the process. Pure bugfix candidate.
Diffstat (limited to 'Python/getargs.c')
-rw-r--r--Python/getargs.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/Python/getargs.c b/Python/getargs.c
index 557389b..451b914 100644
--- a/Python/getargs.c
+++ b/Python/getargs.c
@@ -1083,18 +1083,28 @@ vgetargskeywords(PyObject *args, PyObject *keywords, char *format,
/* make sure there are no duplicate values for an argument;
its not clear when to use the term "keyword argument vs.
keyword parameter in messages */
-
+
if (keywords) {
for (i = 0; i < tplen; i++) {
- if (PyMapping_HasKeyString(keywords, kwlist[i])) {
+ char *thiskw = kwlist[i];
+ if (thiskw == NULL)
+ break;
+ if (PyMapping_HasKeyString(keywords, thiskw)) {
sprintf(msgbuf,
"keyword parameter %s redefined",
- kwlist[i]);
+ thiskw);
PyErr_SetString(PyExc_TypeError, msgbuf);
return 0;
}
}
}
+ /* XXX The loop just above didn't used to break when hitting the
+ end of kwlist, so could pass NULL on to PyMapping_HasKeyString,
+ which sets a "NULL argument to internal routine" error then.
+ However, the comment below doesn't give any clues about which
+ 'error string' it's talking about, so darned hard to say whether
+ the PyErr_Clear() still serves a purpose.
+ */
PyErr_Clear(); /* I'm not which Py functions set the error string */
/* required arguments missing from args can be supplied by keyword