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

Add null pointer checks to avoid segfaults #72

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
add tests
nhz2 committed Sep 16, 2024
commit f399913a32f4c81a2b6db86fe220451179881a5c
35 changes: 35 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -156,6 +156,41 @@ include("utils.jl")
@test CodecZstd.find_decompressed_size(v) == CodecZstd.ZSTD_CONTENTSIZE_ERROR
end

@testset "use after free doesn't segfault" begin
@testset "$(Codec)" for Codec in (ZstdCompressor, ZstdDecompressor)
codec = Codec()
TranscodingStreams.initialize(codec)
TranscodingStreams.finalize(codec)
data = [0x00,0x01]
GC.@preserve data let m = TranscodingStreams.Memory(pointer(data), length(data))
try
TranscodingStreams.expectedsize(codec, m)
catch
end
try
TranscodingStreams.minoutsize(codec, m)
catch
end
try
TranscodingStreams.initialize(codec)
catch
end
try
TranscodingStreams.startproc(codec, :read, TranscodingStreams.Error())
catch
end
try
TranscodingStreams.process(codec, m, m, TranscodingStreams.Error())
catch
end
try
TranscodingStreams.finalize(codec)
catch
end
end
end
end

include("compress_endOp.jl")
include("static_only_tests.jl")
end