Skip to content
Snippets Groups Projects
  • Jeff Epler's avatar
    c4dafcef
    py/mpz: Avoid undefined behavior at integer overflow in mpz_hash. · c4dafcef
    Jeff Epler authored
    Before this, ubsan would detect a problem when executing
    hash(006699999999999999999999999999999999999999999999999999999999999999999999)
    
        ../../py/mpz.c:1539:20: runtime error: left shift of 1067371580458 by
        32 places cannot be represented in type 'mp_int_t' (aka 'long')
    
    When the overflow does occur it now happens as defined by the rules of
    unsigned arithmetic.
    c4dafcef
    History
    py/mpz: Avoid undefined behavior at integer overflow in mpz_hash.
    Jeff Epler authored
    Before this, ubsan would detect a problem when executing
    hash(006699999999999999999999999999999999999999999999999999999999999999999999)
    
        ../../py/mpz.c:1539:20: runtime error: left shift of 1067371580458 by
        32 places cannot be represented in type 'mp_int_t' (aka 'long')
    
    When the overflow does occur it now happens as defined by the rules of
    unsigned arithmetic.
mpz.c 47.53 KiB