Skip to content

Commit 3708316

Browse files
encukouZackerySpytz
authored andcommitted
[3.7] Fix a possible crash due to PyType_FromSpecWithBases() (GH-10304) (GH-13495)
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 8ea0fd8 commit 3708316

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
@@ -2960,6 +2960,7 @@ PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases)
29602960
size_t len = strlen(old_doc)+1;
29612961
char *tp_doc = PyObject_MALLOC(len);
29622962
if (tp_doc == NULL) {
2963+
type->tp_doc = NULL;
29632964
PyErr_NoMemory();
29642965
goto fail;
29652966
}

0 commit comments

Comments
 (0)