From: Victor Stinner Date: Thu, 14 Nov 2013 21:31:41 +0000 (+0100) Subject: Issue #19429, #19437: fix error handling in the OSError constructor X-Git-Tag: v3.4.0b1~275 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=46ef31953e633993e9b97ece6b0d60ed4d3af55f;p=thirdparty%2FPython%2Fcpython.git Issue #19429, #19437: fix error handling in the OSError constructor --- diff --git a/Objects/exceptions.c b/Objects/exceptions.c index 8b109703f7d5..bb61ea5a3c60 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -845,7 +845,7 @@ oserror_init(PyOSErrorObject *self, PyObject **p_args, /* Steals the reference to args */ Py_CLEAR(self->args); self->args = args; - args = NULL; + *p_args = args = NULL; return 0; } @@ -885,11 +885,12 @@ OSError_new(PyTypeObject *type, PyObject *args, PyObject *kwds) PyObject *winerror = NULL; #endif + Py_INCREF(args); + if (!oserror_use_init(type)) { if (!_PyArg_NoKeywords(type->tp_name, kwds)) - return NULL; + goto error; - Py_INCREF(args); if (oserror_parse_args(&args, &myerrno, &strerror, &filename #ifdef MS_WINDOWS , &winerror @@ -932,6 +933,7 @@ OSError_new(PyTypeObject *type, PyObject *args, PyObject *kwds) goto error; } + Py_XDECREF(args); return (PyObject *) self; error: