Prevent NullReferenceException

The variable val was not referenced later in the function and caused a
NullReferenceException.
Merge branch 'moppa-7.0.2' into 7.1.0