The range check was applied before padding up, in the unlikely case sizes (INT_MAX - 2) or (INT_MAX - 1) were passed in, the value overflow into a negative integer.
The range check was applied before padding up, in the unlikely case sizes (INT_MAX - 2) or (INT_MAX - 1) were passed in, the value overflow into a negative integer.