main: fix an Out-of-bounds access