Add nullptr check and return invalid param