ls: check for the index size before using it in visit()

Thanks to k0ga for noticing it!
1 file changed