diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2014-11-18 22:11:05 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2014-11-18 22:11:05 (GMT) |
commit | a86c091a736020d823f1676acec7319bc5493f2c (patch) | |
tree | caafa779077224cfdb8549e03dcf23f43fb5cd18 /Python/ceval.c | |
parent | ead2f5a027c2bb92a1b476c72f1ef50dcec32092 (diff) | |
download | cpython-a86c091a736020d823f1676acec7319bc5493f2c.zip cpython-a86c091a736020d823f1676acec7319bc5493f2c.tar.gz cpython-a86c091a736020d823f1676acec7319bc5493f2c.tar.bz2 |
Issue #22453: Fexed reference leaks when format error messages in ceval.c.
Warn against the use of leaking macro PyObject_REPR().
Diffstat (limited to 'Python/ceval.c')
-rw-r--r-- | Python/ceval.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index e008608..dad5e1c 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1957,9 +1957,13 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) if (err == 0) continue; break; } + t = PyObject_Repr(w); + if (t == NULL) + break; PyErr_Format(PyExc_SystemError, "no locals found when storing %s", - PyObject_REPR(w)); + PyString_AS_STRING(t)); + Py_DECREF(t); break; case DELETE_NAME: @@ -1971,9 +1975,13 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) w); break; } + t = PyObject_Repr(w); + if (t == NULL) + break; PyErr_Format(PyExc_SystemError, "no locals when deleting %s", - PyObject_REPR(w)); + PyString_AS_STRING(w)); + Py_DECREF(t); break; PREDICTED_WITH_ARG(UNPACK_SEQUENCE); @@ -2046,10 +2054,14 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) case LOAD_NAME: w = GETITEM(names, oparg); if ((v = f->f_locals) == NULL) { + why = WHY_EXCEPTION; + t = PyObject_Repr(w); + if (t == NULL) + break; PyErr_Format(PyExc_SystemError, "no locals when loading %s", - PyObject_REPR(w)); - why = WHY_EXCEPTION; + PyString_AS_STRING(w)); + Py_DECREF(t); break; } if (PyDict_CheckExact(v)) { |