Fix buffer overflow reported by John Darrington.