Skip to content

Commit b79735b

Browse files
author
guido.van.rossum
committed
Fix two crashers.
git-svn-id: http://svn.python.org/projects/python/trunk@60224 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 37f8ee7 commit b79735b

4 files changed

Lines changed: 11 additions & 44 deletions

File tree

Lib/test/crashers/borrowed_ref_3.py

Lines changed: 0 additions & 14 deletions
This file was deleted.

Lib/test/crashers/borrowed_ref_4.py

Lines changed: 0 additions & 28 deletions
This file was deleted.

Python/bltinmodule.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1245,11 +1245,14 @@ min_max(PyObject *args, PyObject *kwds, int op)
12451245
"%s() got an unexpected keyword argument", name);
12461246
return NULL;
12471247
}
1248+
Py_INCREF(keyfunc);
12481249
}
12491250

12501251
it = PyObject_GetIter(v);
1251-
if (it == NULL)
1252+
if (it == NULL) {
1253+
Py_XDECREF(keyfunc);
12521254
return NULL;
1255+
}
12531256

12541257
maxitem = NULL; /* the result */
12551258
maxval = NULL; /* the value associated with the result */
@@ -1298,6 +1301,7 @@ min_max(PyObject *args, PyObject *kwds, int op)
12981301
else
12991302
Py_DECREF(maxval);
13001303
Py_DECREF(it);
1304+
Py_XDECREF(keyfunc);
13011305
return maxitem;
13021306

13031307
Fail_it_item_and_val:
@@ -1308,6 +1312,7 @@ min_max(PyObject *args, PyObject *kwds, int op)
13081312
Py_XDECREF(maxval);
13091313
Py_XDECREF(maxitem);
13101314
Py_DECREF(it);
1315+
Py_XDECREF(keyfunc);
13111316
return NULL;
13121317
}
13131318

Python/ceval.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2066,6 +2066,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
20662066
"__import__ not found");
20672067
break;
20682068
}
2069+
Py_INCREF(x);
20692070
v = POP();
20702071
u = TOP();
20712072
if (PyInt_AsLong(u) != -1 || PyErr_Occurred())
@@ -2087,11 +2088,14 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
20872088
Py_DECREF(u);
20882089
if (w == NULL) {
20892090
u = POP();
2091+
Py_DECREF(x);
20902092
x = NULL;
20912093
break;
20922094
}
20932095
READ_TIMESTAMP(intr0);
2094-
x = PyEval_CallObject(x, w);
2096+
v = x;
2097+
x = PyEval_CallObject(v, w);
2098+
Py_DECREF(v);
20952099
READ_TIMESTAMP(intr1);
20962100
Py_DECREF(w);
20972101
SET_TOP(x);

0 commit comments

Comments
 (0)