Fix bufferoverflow found by coverity.