File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -2847,15 +2847,22 @@ PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases)
28472847 char * res_start = (char * )res ;
28482848 PyType_Slot * slot ;
28492849
2850+ if (res == NULL )
2851+ return NULL ;
2852+
2853+ if (spec -> name == NULL ) {
2854+ PyErr_SetString (PyExc_SystemError ,
2855+ "Type spec does not define the name field." );
2856+ goto fail ;
2857+ }
2858+
28502859 /* Set the type name and qualname */
28512860 s = strrchr (spec -> name , '.' );
28522861 if (s == NULL )
28532862 s = (char * )spec -> name ;
28542863 else
28552864 s ++ ;
28562865
2857- if (res == NULL )
2858- return NULL ;
28592866 type = & res -> ht_type ;
28602867 /* The flags must be initialized early, before the GC traverses us */
28612868 type -> tp_flags = spec -> flags | Py_TPFLAGS_HEAPTYPE ;
@@ -2865,8 +2872,6 @@ PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases)
28652872 res -> ht_qualname = res -> ht_name ;
28662873 Py_INCREF (res -> ht_qualname );
28672874 type -> tp_name = spec -> name ;
2868- if (!type -> tp_name )
2869- goto fail ;
28702875
28712876 /* Adjust for empty tuple bases */
28722877 if (!bases ) {
You can’t perform that action at this time.
0 commit comments