Skip to content

Commit

Permalink
fix bounds checking of findnext
Browse files Browse the repository at this point in the history
`findnext(randn(10) .< 0.0, 0)` causes segmentation fault bacause
the start index 0 is out of bounds.
  • Loading branch information
bicycle1885 committed Mar 29, 2014
1 parent 0089203 commit 314923f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions base/bitarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1321,7 +1321,7 @@ end

# returns the index of the next non-zero element, or 0 if all zeros
function findnext(B::BitArray, start::Integer)
if start < 0
if start <= 0
throw(BoundsError())
elseif start > length(B)
return 0
Expand Down Expand Up @@ -1349,7 +1349,7 @@ end

# aux function: same as findnext(~B, start), but performed without temporaries
function findnextnot(B::BitArray, start::Integer)
if start < 0
if start <= 0
throw(BoundsError())
elseif start > length(B)
return 0
Expand Down

0 comments on commit 314923f

Please sign in to comment.