Skip to content

Commit a12d92b

Browse files
committed
merge 3.3 (#27783)
2 parents 10bc0f6 + 1f0e7c9 commit a12d92b

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

Misc/NEWS

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

19+
- Issue #27783: Fix possible usage of uninitialized memory in operator.methodcaller.
20+
1921
- Issue #27774: Fix possible Py_DECREF on unowned object in _sre.
2022

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

Modules/_operator.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ static PyObject *
801801
methodcaller_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
802802
{
803803
methodcallerobject *mc;
804-
PyObject *name, *newargs;
804+
PyObject *name;
805805

806806
if (PyTuple_GET_SIZE(args) < 1) {
807807
PyErr_SetString(PyExc_TypeError, "methodcaller needs at least "
@@ -814,20 +814,19 @@ methodcaller_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
814814
if (mc == NULL)
815815
return NULL;
816816

817-
newargs = PyTuple_GetSlice(args, 1, PyTuple_GET_SIZE(args));
818-
if (newargs == NULL) {
819-
Py_DECREF(mc);
820-
return NULL;
821-
}
822-
mc->args = newargs;
823-
824817
name = PyTuple_GET_ITEM(args, 0);
825818
Py_INCREF(name);
826819
mc->name = name;
827820

828821
Py_XINCREF(kwds);
829822
mc->kwds = kwds;
830823

824+
mc->args = PyTuple_GetSlice(args, 1, PyTuple_GET_SIZE(args));
825+
if (mc->args == NULL) {
826+
Py_DECREF(mc);
827+
return NULL;
828+
}
829+
831830
PyObject_GC_Track(mc);
832831
return (PyObject *)mc;
833832
}

0 commit comments

Comments
 (0)