Fix an overflow bug in sparse index.