PHP-1237: Add extra check for underflow, which theoretically could happen.

Can't find a test case for this though.
Merged pull request #766