fix overbounds errors (from coverity)