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 @@ -2748,15 +2748,22 @@ PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases)
27482748 char * res_start = (char * )res ;
27492749 PyType_Slot * slot ;
27502750
2751+ if (res == NULL )
2752+ return NULL ;
2753+
2754+ if (spec -> name == NULL ) {
2755+ PyErr_SetString (PyExc_SystemError ,
2756+ "Type spec does not define the name field." );
2757+ goto fail ;
2758+ }
2759+
27512760 /* Set the type name and qualname */
27522761 s = strrchr (spec -> name , '.' );
27532762 if (s == NULL )
27542763 s = (char * )spec -> name ;
27552764 else
27562765 s ++ ;
27572766
2758- if (res == NULL )
2759- return NULL ;
27602767 type = & res -> ht_type ;
27612768 /* The flags must be initialized early, before the GC traverses us */
27622769 type -> tp_flags = spec -> flags | Py_TPFLAGS_HEAPTYPE ;
@@ -2766,8 +2773,6 @@ PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases)
27662773 res -> ht_qualname = res -> ht_name ;
27672774 Py_INCREF (res -> ht_qualname );
27682775 type -> tp_name = spec -> name ;
2769- if (!type -> tp_name )
2770- goto fail ;
27712776
27722777 /* Adjust for empty tuple bases */
27732778 if (!bases ) {
You can’t perform that action at this time.
0 commit comments