Skip to content

Commit 0613c1e

Browse files
ZackerySpytzencukou
authored andcommitted
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().
1 parent e657624 commit 0613c1e

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

Objects/typeobject.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2995,6 +2995,7 @@ PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases)
29952995
size_t len = strlen(old_doc)+1;
29962996
char *tp_doc = PyObject_MALLOC(len);
29972997
if (tp_doc == NULL) {
2998+
type->tp_doc = NULL;
29982999
PyErr_NoMemory();
29993000
goto fail;
30003001
}

0 commit comments

Comments
 (0)