Fix out of buffer read when value of --type-index was too big Co-authored-by: Alexandre Ganea <aganea@havenstudios.com>