Fix #1421 Overflow issue
Merge pull request #609 from nlegoff/fix_1421

[3.8] Fix 1421 overflow issue