Avoid signed integer underflow when comparing versions (Fix TROVE-2017-001)

There's a medium-severity bug to fix here.