Fixes #3833 adding check upstream. Thx for the report & patch, very nice bug to fix!