diff options
| author | Vexu <git@vexu.eu> | 2020-05-12 01:25:24 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-12 01:25:24 +0300 |
| commit | 7aee8a93ebc199dd5ff94387f0906699d795c138 (patch) | |
| tree | 2a500c59212998b0dfb0671cf8f8556f9de0f558 /src/bigint.cpp | |
| parent | 3e3c651b670fb45e714db1cfb32428c3ea3cd828 (diff) | |
| parent | 204f8daeeda02738479e0d586e6426e23f78e6cc (diff) | |
| download | zig-7aee8a93ebc199dd5ff94387f0906699d795c138.tar.gz zig-7aee8a93ebc199dd5ff94387f0906699d795c138.zip | |
Merge pull request #5315 from xackus/fix-bigint_fits_in_bits
stage1: detect underflow in bigint_fits_in_bits
Diffstat (limited to 'src/bigint.cpp')
| -rw-r--r-- | src/bigint.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/bigint.cpp b/src/bigint.cpp index dd04363e82..79a05e95a5 100644 --- a/src/bigint.cpp +++ b/src/bigint.cpp @@ -243,6 +243,7 @@ bool bigint_fits_in_bits(const BigInt *bn, size_t bit_count, bool is_signed) { } if (!is_signed) { + if(bn->is_negative) return false; size_t full_bits = bn->digit_count * 64; size_t leading_zero_count = bigint_clz(bn, full_bits); return bit_count >= full_bits - leading_zero_count; |
