@@ -73,16 +73,22 @@ int PyStructSequence_InitType2(PyTypeObject *type, PyStructSequence_Desc *desc)
7373 PyObject * field_docs = PyTuple_New (n_members );
7474 PyStructSequence_Field * fields = desc -> fields ;
7575 for (i = 0 ; i < n_members ; i ++ ) {
76- PyTuple_SetItem (field_names , i , polyglot_from_string (fields [i ].name , SRC_CS ));
77- PyTuple_SetItem (field_docs , i , polyglot_from_string (fields [i ].doc , SRC_CS ));
76+ PyTuple_SetItem (field_names , i , polyglot_from_string (fields [i ].name , SRC_CS ));
77+ PyTuple_SetItem (field_docs , i , polyglot_from_string (fields [i ].doc , SRC_CS ));
7878 }
7979
8080 // we create the new type managed
8181 PyTypeObject * newType = (PyTypeObject * ) UPCALL_CEXT_O (_jls_PyStructSequence_InitType2 ,
82- polyglot_from_string (desc -> name , SRC_CS ),
83- polyglot_from_string (desc -> doc , SRC_CS ),
84- native_to_java (field_names ),
85- native_to_java (field_docs ));
82+ polyglot_from_string (desc -> name , SRC_CS ),
83+ polyglot_from_string (desc -> doc , SRC_CS ),
84+ native_to_java (field_names ),
85+ native_to_java (field_docs ));
86+
87+ if (newType == NULL ) {
88+ Py_DECREF (field_names );
89+ Py_DECREF (field_docs );
90+ return -1 ;
91+ }
8692
8793 // copy generic fields (CPython mem-copies a template)
8894 type -> tp_basicsize = sizeof (PyStructSequence ) - sizeof (PyObject * );
0 commit comments