Re #8361. Move heap allocation after ParameterReference creation.

The ParameterReference constructor can throw, which was leaking the
new'd double.