extractNumber does check the type of the BSONElement before extracting its value, but it does not defend against non-finite floating point numbers.