Skip to content

Commit 717f9ae

Browse files
committed
Fix: pageLocations is initialized with a negative number of elements
Occured for small inputs when not using initial optimizations.
1 parent d2ea0a7 commit 717f9ae

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/SortingAlgorithms.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ function sort!(v::AbstractVector, lo::Integer, hi::Integer, ::PagedMergeSortAlg,
925925
pagesize = isqrt(n)
926926
scratch = Vector{eltype(v)}(undef, 3pagesize)
927927
nPages = n ÷ pagesize
928-
pageLocations = Vector{Int}(undef, nPages - 3)
928+
pageLocations = Vector{Int}(undef, max(0, nPages - 3))
929929
pagedmergesort!(v, lo, hi, o, scratch, pageLocations)
930930
return v
931931
end

0 commit comments

Comments
 (0)