diff options
author | Benjamin Peterson <benjamin@python.org> | 2016-08-17 06:37:33 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2016-08-17 06:37:33 (GMT) |
commit | 6423429325f4f2309892f530417bc9737268be38 (patch) | |
tree | 09ffa4230648c77570e136cdd419fbf6d3dcdf5a | |
parent | 379a3ffaf21f89720f0f052802a09672a54d8dd3 (diff) | |
parent | a12d92bec1858a76f2c5519bce07c8a00a891207 (diff) | |
download | cpython-6423429325f4f2309892f530417bc9737268be38.zip cpython-6423429325f4f2309892f530417bc9737268be38.tar.gz cpython-6423429325f4f2309892f530417bc9737268be38.tar.bz2 |
merge 3.4 (#27783)
-rw-r--r-- | Misc/NEWS | 2 | ||||
-rw-r--r-- | Modules/_operator.c | 16 |
2 files changed, 10 insertions, 8 deletions
@@ -42,6 +42,8 @@ Library - In the curses module, raise an error if window.getstr() or window.instr() is passed a negative value. +- Issue #27783: Fix possible usage of uninitialized memory in operator.methodcaller. + - Issue #27774: Fix possible Py_DECREF on unowned object in _sre. - Issue #27760: Fix possible integer overflow in binascii.b2a_qp. diff --git a/Modules/_operator.c b/Modules/_operator.c index eb4f3a3..dfff1d2 100644 --- a/Modules/_operator.c +++ b/Modules/_operator.c @@ -931,7 +931,7 @@ static PyObject * methodcaller_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { methodcallerobject *mc; - PyObject *name, *newargs; + PyObject *name; if (PyTuple_GET_SIZE(args) < 1) { PyErr_SetString(PyExc_TypeError, "methodcaller needs at least " @@ -951,13 +951,7 @@ methodcaller_new(PyTypeObject *type, PyObject *args, PyObject *kwds) if (mc == NULL) return NULL; - newargs = PyTuple_GetSlice(args, 1, PyTuple_GET_SIZE(args)); - if (newargs == NULL) { - Py_DECREF(mc); - return NULL; - } - mc->args = newargs; - + name = PyTuple_GET_ITEM(args, 0); Py_INCREF(name); PyUnicode_InternInPlace(&name); mc->name = name; @@ -965,6 +959,12 @@ methodcaller_new(PyTypeObject *type, PyObject *args, PyObject *kwds) Py_XINCREF(kwds); mc->kwds = kwds; + mc->args = PyTuple_GetSlice(args, 1, PyTuple_GET_SIZE(args)); + if (mc->args == NULL) { + Py_DECREF(mc); + return NULL; + } + PyObject_GC_Track(mc); return (PyObject *)mc; } |