Fix null pointer dereference in indexing code.