mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
Fix a possible crash due to PyType_FromSpecWithBases() (GH-10304)
If the PyObject_MALLOC() call failed in PyType_FromSpecWithBases(), PyObject_Free() would be called on a static string in type_dealloc().
This commit is contained in:
parent
e6576248e5
commit
0613c1e481
1 changed files with 1 additions and 0 deletions
|
|
@ -2995,6 +2995,7 @@ PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases)
|
||||||
size_t len = strlen(old_doc)+1;
|
size_t len = strlen(old_doc)+1;
|
||||||
char *tp_doc = PyObject_MALLOC(len);
|
char *tp_doc = PyObject_MALLOC(len);
|
||||||
if (tp_doc == NULL) {
|
if (tp_doc == NULL) {
|
||||||
|
type->tp_doc = NULL;
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue