fix buffer overflow when loading index