[Python-checkins] cpython: fix refleaks
benjamin.peterson
python-checkins at python.org
Thu Nov 14 05:50:17 CET 2013
http://hg.python.org/cpython/rev/c27237d57231
changeset: 87097:c27237d57231
user: Benjamin Peterson <benjamin at python.org>
date: Wed Nov 13 23:49:49 2013 -0500
summary:
fix refleaks
files:
Objects/exceptions.c | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -2683,6 +2683,9 @@
* state potentially stored on OSError instances.
*/
+ Py_DECREF(exc);
+ Py_XDECREF(tb);
+
#ifdef HAVE_STDARG_PROTOTYPES
va_start(vargs, format);
#else
@@ -2690,13 +2693,14 @@
#endif
msg_prefix = PyUnicode_FromFormatV(format, vargs);
va_end(vargs);
- if (msg_prefix == NULL)
+ if (msg_prefix == NULL) {
+ Py_DECREF(val);
return NULL;
+ }
PyErr_Format(exc, "%U (%s: %S)",
msg_prefix, Py_TYPE(val)->tp_name, val);
- Py_DECREF(exc);
- Py_XDECREF(tb);
+ Py_DECREF(msg_prefix);
PyErr_Fetch(&new_exc, &new_val, &new_tb);
PyErr_NormalizeException(&new_exc, &new_val, &new_tb);
PyException_SetCause(new_val, val);
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list