fixes for CVE CVE-2013-6424:

If t->bottom is close to MIN_INT, removing top can wraparound, so do the check properly.