check pointers before refing them in swig wrappers