Added checks to prevent overflow.
1 file changed