[Python-checkins] cpython: fix refleak on error

benjamin.peterson python-checkins at python.org
Sun Jan 26 16:24:30 CET 2014


http://hg.python.org/cpython/rev/406ef1101d7d
changeset: 88724:406ef1101d7d
user: Benjamin Peterson <benjamin at python.org>
date: Sun Jan 26 10:24:24 2014 -0500
summary:
 fix refleak on error
files:
 Modules/audioop.c | 11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/Modules/audioop.c b/Modules/audioop.c
--- a/Modules/audioop.c
+++ b/Modules/audioop.c
@@ -1608,7 +1608,7 @@
 Py_ssize_t i;
 int step, valpred, delta,
 index, sign, vpdiff, diff;
- PyObject *rv, *str;
+ PyObject *rv = NULL, *str;
 int outputbuffer = 0, bufferstep;
 
 if (!audioop_check_parameters(fragment->len, width))
@@ -1626,9 +1626,10 @@
 index = 0;
 } else if (!PyTuple_Check(state)) {
 PyErr_SetString(PyExc_TypeError, "state must be a tuple or None");
- return NULL;
- } else if (!PyArg_ParseTuple(state, "ii", &valpred, &index))
- return NULL;
+ goto exit;
+ } else if (!PyArg_ParseTuple(state, "ii", &valpred, &index)) {
+ goto exit;
+ }
 
 step = stepsizeTable[index];
 bufferstep = 1;
@@ -1704,6 +1705,8 @@
 bufferstep = !bufferstep;
 }
 rv = Py_BuildValue("(O(ii))", str, valpred, index);
+
+ exit:
 Py_DECREF(str);
 return rv;
 }
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /