diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-06-30 21:37:47 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-06-30 21:37:47 (GMT) |
commit | f87289bb58e71f5df73cbd594cbc0c0515e91c4b (patch) | |
tree | 0ab9487f6c843687835426960fab5e3eb6316eae /Objects/exceptions.c | |
parent | 4c99071c9be1cf81e915ebfcb17dcf50c6e489d6 (diff) | |
download | cpython-f87289bb58e71f5df73cbd594cbc0c0515e91c4b.zip cpython-f87289bb58e71f5df73cbd594cbc0c0515e91c4b.tar.gz cpython-f87289bb58e71f5df73cbd594cbc0c0515e91c4b.tar.bz2 |
Issue #15229: An OSError subclass whose __init__ doesn't call back
OSError.__init__ could produce incomplete instances, leading to crashes
when calling str() on them.
Diffstat (limited to 'Objects/exceptions.c')
-rw-r--r-- | Objects/exceptions.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Objects/exceptions.c b/Objects/exceptions.c index f706698..5c85f10 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -834,6 +834,7 @@ oserror_init(PyOSErrorObject *self, PyObject **p_args, #endif /* Steals the reference to args */ + Py_CLEAR(self->args); self->args = args; args = NULL; @@ -916,6 +917,11 @@ OSError_new(PyTypeObject *type, PyObject *args, PyObject *kwds) )) goto error; } + else { + self->args = PyTuple_New(0); + if (self->args == NULL) + goto error; + } return (PyObject *) self; |