Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e109ee8

Browse files
committed
fix refleaks
1 parent 079c998 commit e109ee8

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

Objects/exceptions.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2683,20 +2683,24 @@ _PyErr_TrySetFromCause(const char *format, ...)
26832683
* state potentially stored on OSError instances.
26842684
*/
26852685

2686+
Py_DECREF(exc);
2687+
Py_XDECREF(tb);
2688+
26862689
#ifdef HAVE_STDARG_PROTOTYPES
26872690
va_start(vargs, format);
26882691
#else
26892692
va_start(vargs);
26902693
#endif
26912694
msg_prefix = PyUnicode_FromFormatV(format, vargs);
26922695
va_end(vargs);
2693-
if (msg_prefix == NULL)
2696+
if (msg_prefix == NULL) {
2697+
Py_DECREF(val);
26942698
return NULL;
2699+
}
26952700

26962701
PyErr_Format(exc, "%U (%s: %S)",
26972702
msg_prefix, Py_TYPE(val)->tp_name, val);
2698-
Py_DECREF(exc);
2699-
Py_XDECREF(tb);
2703+
Py_DECREF(msg_prefix);
27002704
PyErr_Fetch(&new_exc, &new_val, &new_tb);
27012705
PyErr_NormalizeException(&new_exc, &new_val, &new_tb);
27022706
PyException_SetCause(new_val, val);

0 commit comments

Comments
 (0)