Skip to content

Commit

Permalink
Restrict path to be an AbstractString in lbt_forward()
Browse files Browse the repository at this point in the history
Some users tried to pass a `dlopen()` handle into `lbt_forward()` which sadly works just fine, despite `ccall()` declaring its first argument as being a `Cstring`.  I guess it's trivial to convert a `Ptr{Cvoid}` into a `Cstring`, so this just goes through.

To protect against this, restrict `path` to be an `AbstractString`.
  • Loading branch information
staticfloat committed Feb 7, 2023
1 parent 3fe69f4 commit 8492031
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions stdlib/LinearAlgebra/src/lbt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,10 @@ function lbt_set_num_threads(nthreads)
return ccall((:lbt_set_num_threads, libblastrampoline), Cvoid, (Int32,), nthreads)
end

function lbt_forward(path; clear::Bool = false, verbose::Bool = false, suffix_hint::Union{String,Nothing} = nothing)
function lbt_forward(path::AbstractString; clear::Bool = false, verbose::Bool = false, suffix_hint::Union{String,Nothing} = nothing)
_clear_config_with() do
return ccall((:lbt_forward, libblastrampoline), Int32, (Cstring, Int32, Int32, Cstring), path, clear ? 1 : 0, verbose ? 1 : 0, something(suffix_hint, C_NULL))
return ccall((:lbt_forward, libblastrampoline), Int32, (Cstring, Int32, Int32, Cstring),
path, clear ? 1 : 0, verbose ? 1 : 0, something(suffix_hint, C_NULL))
end
end

Expand Down

0 comments on commit 8492031

Please sign in to comment.