Issue #19429, #19437: fix error handling in the OSError constructor

This commit is contained in:
Victor Stinner 2013-11-14 22:31:41 +01:00
parent b03142782c
commit 46ef31953e
1 changed files with 5 additions and 3 deletions

View File

@ -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: