Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Reworked, even cruder bound, that avoids potential issues with intege…
…r overflow
  • Loading branch information
mdickinson committed Sep 3, 2022
commit 66a07ac000546ea6e5ead8498ccfeb32b6b76f13
4 changes: 1 addition & 3 deletions Objects/longobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1766,9 +1766,7 @@ long_to_decimal_string_internal(PyObject *aa,
PyInterpreterState *interp = _PyInterpreterState_GET();
int max_str_digits = interp->int_max_str_digits;
if ((max_str_digits > 0) &&
/* avoid overflow in 10 * max_str_digits */
(max_str_digits <= INT_MAX / 10) &&
(size_a >= 10 * max_str_digits / (3 * PyLong_SHIFT) + 2)) {
(max_str_digits / (3 * PyLong_SHIFT) <= (size_a - 11) / 10)) {
PyErr_Format(PyExc_ValueError, _MAX_STR_DIGITS_ERROR_FMT2,
max_str_digits);
return -1;
Expand Down