fix array index being to big, causes #6118