Fixed buffer overrun (fencepost error)

Fixed buffer overrun (fencepost error) where vector indices were being pre- rather than post-incremented.