Coverity: fix potential buffer overflow