Resolve possible buffer overflow (as per cppcheck / Paul Wise)