Wow. That's a crazy edge case indeed (just looking at the code below). The fix looks reasonable though.