Reduce scope for a variable

(Found by cppcheck)