Skip to content

Commit

Permalink
#34997: check first to avoid executing the UB
Browse files Browse the repository at this point in the history
  • Loading branch information
tornaria committed Feb 8, 2023
1 parent 910a2e9 commit 15f37f7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/sage/arith/long.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,12 @@ cdef inline bint integer_check_long_py(x, long* value, int* err):

cdef long lead
cdef long lead_2_overflow = (<long>1) << (BITS_IN_LONG - PyLong_SHIFT)
cdef long lead_3_overflow = (<long>1) << (BITS_IN_LONG - 2 * PyLong_SHIFT)
cdef long lead_3_overflow
if BITS_IN_LONG < 2 * PyLong_SHIFT:
# in this case 3 digit is always overflow
lead_3_overflow = 0
else:
lead_3_overflow = (<long>1) << (BITS_IN_LONG - 2 * PyLong_SHIFT)
if size == 0:
value[0] = 0
err[0] = 0
Expand Down

0 comments on commit 15f37f7

Please sign in to comment.