Skip to content

Commit fda02ac

Browse files
authoredApr 20, 2024
use correct size when creating output data from an IOBuffer (#54129)
PR from #54097. Fixes #54097 Co-authored-by: Nathan Zimmerberg
1 parent dd443f2 commit fda02ac

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed
 

‎base/iobuffer.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ function take!(io::IOBuffer)
468468
elseif io.writable
469469
data = view(io.data, io.offset+1:nbytes+io.offset)
470470
else
471-
data = copyto!(StringVector(io.size), 1, io.data, io.offset + 1, nbytes)
471+
data = copyto!(StringVector(nbytes), 1, io.data, io.offset + 1, nbytes)
472472
end
473473
else
474474
nbytes = bytesavailable(io)

‎test/iobuffer.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,3 +383,8 @@ end
383383
seek(io,0)
384384
@test Base.read_sub(io,v,1,1) == [1,0]
385385
end
386+
387+
@testset "with offset" begin
388+
b = pushfirst!([0x02], 0x01)
389+
@test take!(IOBuffer(b)) == [0x01, 0x02]
390+
end

0 commit comments

Comments
 (0)
Please sign in to comment.