diff options
| author | Antoine Pitrou <solipsis@pitrou.net> | 2012-06-30 23:37:47 +0200 |
|---|---|---|
| committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-06-30 23:37:47 +0200 |
| commit | bcbe5a00c5420c84bc80f14aff0ca42e779fed3a (patch) | |
| tree | 046446cd32832acfecc50c6e919fa2b34c26a970 /Objects | |
| parent | ddc4fdd5df7b6a81e923fd9c4ad64d4806c4f14d (diff) | |
| download | cpython-bcbe5a00c5420c84bc80f14aff0ca42e779fed3a.tar.gz | |
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')
| -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 f706698499..5c85f10444 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; |
