diff options
| author | Jeff Epler <jepler@gmail.com> | 2025-06-11 19:32:28 +0200 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2025-06-16 12:11:07 +1000 |
| commit | 0ef5ede3823ef00e95d1cc1a5b475d8d30c9caa4 (patch) | |
| tree | b14eec63b1b583f0396e63f874142a096330bb3c /tests | |
| parent | 42404b5588eb12c22e07283f2e62ee9bb80f1714 (diff) | |
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>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ports/unix/extra_coverage.py.exp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/ports/unix/extra_coverage.py.exp b/tests/ports/unix/extra_coverage.py.exp index 19b32f1c9..154916822 100644 --- a/tests/ports/unix/extra_coverage.py.exp +++ b/tests/ports/unix/extra_coverage.py.exp @@ -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' |
