The day the world went away
Sorry. Upon reinvestigation, I realized I had been looking at the wrong frame while stepping through in the debugger. It looks like this is hitting an edge case after all. It will take some further research to work out the correct ESV calculation, but what is currently there works correctly is the vast majority of cases (I can't give an actual percentage of cases where it's correct, but I would guess over 95%).