To get rid of undefined behavior. BUG:456922 BUG:439145
Should this be backported before the beta?
mentioned in commit 07108aaa