diff options
author | Benjamin Peterson <benjamin@python.org> | 2013-11-14 04:49:49 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2013-11-14 04:49:49 (GMT) |
commit | e109ee820523cbc9802dc238e842eba7b7fa7e74 (patch) | |
tree | d71180dda594469974d3894cc0a48ded24aaab33 /Objects/exceptions.c | |
parent | 079c9988729dfe67c657718593a0ae66f6d45b1e (diff) | |
download | cpython-e109ee820523cbc9802dc238e842eba7b7fa7e74.zip cpython-e109ee820523cbc9802dc238e842eba7b7fa7e74.tar.gz cpython-e109ee820523cbc9802dc238e842eba7b7fa7e74.tar.bz2 |
fix refleaks
Diffstat (limited to 'Objects/exceptions.c')
-rw-r--r-- | Objects/exceptions.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Objects/exceptions.c b/Objects/exceptions.c index 53dab62..8b10970 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -2683,6 +2683,9 @@ _PyErr_TrySetFromCause(const char *format, ...) * 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 @@ _PyErr_TrySetFromCause(const char *format, ...) #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); |