Fixed possible overrun issue found by Coverity