ensure the pointer is valid before using it