Skip to content

Commit 1e5e941

Browse files
ZackerySpytzencukou
authored andcommitted
[3.7] 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(). (cherry picked from commit 0613c1e) Co-authored-by: Zackery Spytz <[email protected]>
1 parent d092caf commit 1e5e941

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
@@ -2938,6 +2938,7 @@ PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases)
29382938
size_t len = strlen(old_doc)+1;
29392939
char *tp_doc = PyObject_MALLOC(len);
29402940
if (tp_doc == NULL) {
2941+
type->tp_doc = NULL;
29412942
PyErr_NoMemory();
29422943
goto fail;
29432944
}

0 commit comments

Comments
 (0)