Skip to content

Commit

Permalink
fix rawbigints OOB issues (#55917)
Browse files Browse the repository at this point in the history
Fixes issues introduced in #50691 and found in #55906:
* use `@inbounds` and `@boundscheck` macros in rawbigints, for catching
OOB with `--check-bounds=yes`
* fix OOB in `truncate`

(cherry picked from commit 17445fe)
  • Loading branch information
nsajko authored and KristofferC committed Oct 7, 2024
1 parent 501a4f2 commit 099d07f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test/mpfr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1055,3 +1055,12 @@ end
end
end
end

@testset "RawBigInt truncation OOB read" begin
@testset "T: $T" for T (UInt8, UInt16, UInt32, UInt64, UInt128)
v = Base.RawBigInt{T}("a"^sizeof(T), 1)
@testset "bit_count: $bit_count" for bit_count (0:10:80)
@test Base.truncated(UInt128, v, bit_count) isa Any
end
end
end

0 comments on commit 099d07f

Please sign in to comment.