Use function is_valid_pointer (also checks for maximum size).