Issue #5251: fix hidden overflow

Well, this is my first PR, so I hope everything is ok.