diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-11-14 21:31:41 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-11-14 21:31:41 (GMT) |
commit | 46ef31953e633993e9b97ece6b0d60ed4d3af55f (patch) | |
tree | 7420119dc25fc1fa8261e584108697d3f94f5b9f /Objects | |
parent | b03142782c84c3ce6ba0a86a3af93c08b84f32e6 (diff) | |
download | cpython-46ef31953e633993e9b97ece6b0d60ed4d3af55f.zip cpython-46ef31953e633993e9b97ece6b0d60ed4d3af55f.tar.gz cpython-46ef31953e633993e9b97ece6b0d60ed4d3af55f.tar.bz2 |
Issue #19429, #19437: fix error handling in the OSError constructor
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/exceptions.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Objects/exceptions.c b/Objects/exceptions.c index 8b10970..bb61ea5 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: |