Skip to content

Commit eed18bd

Browse files
authored
iobuffer: copyline: type assert Int to prevent invalidation (#57848)
Should prevent invalidation stemming from `MethodInstance`s for * `readline()` * `readlines()` * `Base.run_fallback_repl(::Bool)` * `Base.repl_main(::Any)` * `Base._start()` In each case the issue is the use of the nonconcretely-typed global variable `stdin::IO`.
1 parent 0d2a36f commit eed18bd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

base/iobuffer.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ function _copyline(out::IO, io::GenericIOBuffer; keep::Bool=false)
643643
data = view(io.data, io.ptr:io.size)
644644
# note: findfirst + copyto! is much faster than a single loop
645645
# except for nout ≲ 20. A single loop is 2x faster for nout=5.
646-
nout = nread = something(findfirst(==(0x0a), data), length(data))
646+
nout = nread = something(findfirst(==(0x0a), data), length(data))::Int
647647
if !keep && nout > 0 && data[nout] == 0x0a
648648
nout -= 1
649649
nout > 0 && data[nout] == 0x0d && (nout -= 1)

0 commit comments

Comments
 (0)