Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid type pirating Base.skip #150

Open
KristofferC opened this issue Nov 10, 2022 · 0 comments
Open

Avoid type pirating Base.skip #150

KristofferC opened this issue Nov 10, 2022 · 0 comments

Comments

@KristofferC
Copy link
Member

This function seems a bit odd to define here:

Tar.jl/src/Tar.jl

Lines 12 to 21 in 6bfc114

function Base.skip(io::Union{Base.Process, Base.ProcessChain}, n::Integer)
n < 0 && throw(ArgumentError("cannot skip backwards when reading from a process"))
isempty(skip_buffer) && resize!(skip_buffer, DEFAULT_BUFFER_SIZE)
while n > 0
n -= readbytes!(io, skip_buffer, min(n, length(skip_buffer)))
end
# TODO: our skip data should throw if there's not enough data
return io
end
const skip_buffer = UInt8[]

It also has some issues, like referencing a global skip_buffer (so the function is not thread-safe).

@StefanKarpinski StefanKarpinski changed the title Avoid type piracing Base.skip Avoid type pirating Base.skip Dec 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant