Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4d02b1b

Browse files
committed
merge 3.5 (#27783)
2 parents 17061a9 + 6423429 commit 4d02b1b

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ Library
110110
- In the curses module, raise an error if window.getstr() or window.instr() is
111111
passed a negative value.
112112

113+
- Issue #27783: Fix possible usage of uninitialized memory in operator.methodcaller.
114+
113115
- Issue #27774: Fix possible Py_DECREF on unowned object in _sre.
114116

115117
- Issue #27760: Fix possible integer overflow in binascii.b2a_qp.

Modules/_operator.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ static PyObject *
931931
methodcaller_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
932932
{
933933
methodcallerobject *mc;
934-
PyObject *name, *newargs;
934+
PyObject *name;
935935

936936
if (PyTuple_GET_SIZE(args) < 1) {
937937
PyErr_SetString(PyExc_TypeError, "methodcaller needs at least "
@@ -951,20 +951,20 @@ methodcaller_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
951951
if (mc == NULL)
952952
return NULL;
953953

954-
newargs = PyTuple_GetSlice(args, 1, PyTuple_GET_SIZE(args));
955-
if (newargs == NULL) {
956-
Py_DECREF(mc);
957-
return NULL;
958-
}
959-
mc->args = newargs;
960-
954+
name = PyTuple_GET_ITEM(args, 0);
961955
Py_INCREF(name);
962956
PyUnicode_InternInPlace(&name);
963957
mc->name = name;
964958

965959
Py_XINCREF(kwds);
966960
mc->kwds = kwds;
967961

962+
mc->args = PyTuple_GetSlice(args, 1, PyTuple_GET_SIZE(args));
963+
if (mc->args == NULL) {
964+
Py_DECREF(mc);
965+
return NULL;
966+
}
967+
968968
PyObject_GC_Track(mc);
969969
return (PyObject *)mc;
970970
}

0 commit comments

Comments
 (0)