dict.c/dictRehash: check if rehash ends at last

We should check if the rehash operation ends at last,
because it may cause protential inconsistency.
e.g. `if (d->ht[0].size == 0)` (line 409 488 882)