Skip to content

Commit fcfaa18

Browse files
committed
Add missing nullptr checks
1 parent 666108e commit fcfaa18

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

atom/src/atomlist.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,16 +785,26 @@ class AtomCListHandler : public AtomListHandler
785785
{
786786
static char *kwlist[] = { "key", "reverse", 0 };
787787
// Get a reference to builtins (borrowed ref hence the incref)
788-
cppy::ptr builtins( cppy::incref( PyImport_AddModule("builtins") ) );
788+
cppy::ptr builtins( cppy::xincref( PyImport_AddModule("builtins") ) );
789+
if ( !builtins )
790+
return 0;
789791
cppy::ptr super_type( builtins.getattr( "super" ) );
792+
if ( !super_type )
793+
return 0;
790794
// Create super args (tuple steals references)
791795
cppy::ptr super_args( PyTuple_New(2) );
796+
if ( !super_args )
797+
return 0;
792798
PyTuple_SET_ITEM( super_args.get(), 0, cppy::incref( pyobject_cast( Py_TYPE(m_list.get()) ) ) );
793799
PyTuple_SET_ITEM( super_args.get(), 1, cppy::incref( m_list.get() ) );
794800

795801
// Get and call super method
796802
cppy::ptr super( super_type.call( super_args ) );
803+
if ( !super )
804+
return 0;
797805
cppy::ptr meth( super.getattr( "sort" ) );
806+
if ( !meth )
807+
return 0;
798808
cppy::ptr res( meth.call(args, kwargs) );
799809
if( !res )
800810
return 0;

0 commit comments

Comments
 (0)