mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
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.
This commit is contained in:
parent
4c99071c9b
commit
f87289bb58
3 changed files with 19 additions and 0 deletions
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue