Skip to content

Commit 8f9fa49

Browse files
committed
fix: fix possible StackOverflowErrors for remake_buffer & InitializationProblems
For `InitializationProblem`s `state_values(prob)` can return `nothing`, so calls like `remake_buffer(prob, state_values(prob), keys(u0), values(u0))` would lead to `StackOverflowError`s due to the fallback for the deprecated `Dict` method. This can crash julia if depwarns are enabled.
1 parent 1e08e11 commit 8f9fa49

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/remake.jl

+2
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ function remake_buffer(sys, oldbuffer::AbstractArray, idxs, vals)
5555
return newbuffer
5656
end
5757

58+
remake_buffer(sys, ::Nothing, idxs, vals) = nothing
59+
5860
function remake_buffer(sys, oldbuffer, idxs, vals)
5961
remake_buffer(sys, oldbuffer, Dict(idxs .=> vals))
6062
end

test/remake_test.jl

+2
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,5 @@ for (buf, newbuf, idxs, vals) in [
7171
@test newbuf == _newbuf # test values
7272
@test typeof(newbuf) == typeof(_newbuf) # ensure appropriate type
7373
end
74+
75+
@test isnothing(remake_buffer(sys, nothing, [], []))

0 commit comments

Comments
 (0)