mirror of
https://github.com/micropython/micropython.git
synced 2026-01-04 19:20:22 +01:00
py/mpz: Avoid undefined behavior decrementing NULL.
In the case where an mpz number is zero, its `len` is 0 and its `dig` is NULL. In that case, decrementing NULL via `d--` is undefined behavior according to the C specification. Restructuring the loops in this way avoids undefined behavior. Also, ensure that these cases are tested in the coverage test. This doesn't make much difference now, but would otherwise cause errors later when the undefined behavior sanitizer is employed in CI. Signed-off-by: Jeff Epler <jepler@gmail.com>
This commit is contained in:
committed by
Damien George
parent
42404b5588
commit
0ef5ede382
@@ -89,6 +89,10 @@ data
|
||||
12345
|
||||
6
|
||||
-1
|
||||
0
|
||||
1
|
||||
0
|
||||
0.000000
|
||||
# runtime utils
|
||||
TypeError: unsupported type for __abs__: 'str'
|
||||
TypeError: unsupported types for __divmod__: 'str', 'str'
|
||||
|
||||
Reference in New Issue
Block a user