cherryPicked from gatgui fork:
Fix out of bound subscript in std::vector