Commit b2dc5c22 authored by Robert Bradshaw's avatar Robert Bradshaw

Avoid using abs with arbitrarily-sized ints.

Here the residue always fits into an int.  This fixes #1721.
parent f8cbb006
......@@ -656,21 +656,21 @@ static CYTHON_INLINE PyObject* {{TO_PY_FUNCTION}}({{TYPE}} value, Py_ssize_t wid
int digit_pos;
switch (format_char) {
case 'o':
digit_pos = abs(remaining % (8*8));
digit_pos = abs((int)(remaining % (8*8)));
remaining = remaining / (8*8);
dpos -= 2;
*(uint16_t*)dpos = ((uint16_t*)DIGIT_PAIRS_8)[digit_pos]; /* copy 2 digits at a time */
last_one_off = (digit_pos < 8);
break;
case 'd':
digit_pos = abs(remaining % (10*10));
digit_pos = abs((int)(remaining % (10*10)));
remaining = remaining / (10*10);
dpos -= 2;
*(uint16_t*)dpos = ((uint16_t*)DIGIT_PAIRS_10)[digit_pos]; /* copy 2 digits at a time */
last_one_off = (digit_pos < 10);
break;
case 'x':
*(--dpos) = hex_digits[abs(remaining % 16)];
*(--dpos) = hex_digits[abs((int)(remaining % 16))];
remaining = remaining / 16;
break;
default:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment