]> granicus.if.org Git - python/commitdiff
Fix a possible crash due to PyType_FromSpecWithBases() (GH-10304)
authorZackery Spytz <zspytz@gmail.com>
Thu, 9 May 2019 18:33:32 +0000 (12:33 -0600)
committerPetr Viktorin <pviktori@redhat.com>
Thu, 9 May 2019 18:33:31 +0000 (14:33 -0400)
If the PyObject_MALLOC() call failed in PyType_FromSpecWithBases(),
PyObject_Free() would be called on a static string in type_dealloc().

Objects/typeobject.c

index eeaae1f9f789475c68a54c7a1dab22ad8bc0aaf1..b28f494962ecbd30e00b5276233ede33adc25cbc 100644 (file)
@@ -2995,6 +2995,7 @@ PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases)
             size_t len = strlen(old_doc)+1;
             char *tp_doc = PyObject_MALLOC(len);
             if (tp_doc == NULL) {
+                type->tp_doc = NULL;
                 PyErr_NoMemory();
                 goto fail;
             }