Check ptr for NULL.