Skip to content

Commit f2b268c

Browse files
authored
Merge pull request #230 from johanbluecreek/228-segfaults_with_subs_and_zoo
Resolving remaining issues with segfaults from the use of subs() and infinities (issue #228)
2 parents 675443d + 1b9b551 commit f2b268c

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/subs.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ subs(ex, x=>1, y=>1) # ditto
1818
"""
1919
function subs(ex::T, var::S, val) where {T<:SymbolicType, S<:SymbolicType}
2020
s = Basic()
21-
ccall((:basic_subs2, libsymengine), Nothing, (Ref{Basic}, Ref{Basic}, Ref{Basic}, Ref{Basic}), s, ex, var, val)
21+
err_code = ccall((:basic_subs2, libsymengine), Cuint, (Ref{Basic}, Ref{Basic}, Ref{Basic}, Ref{Basic}), s, ex, var, val)
22+
throw_if_error(err_code, ex)
2223
return s
2324
end
2425
function subs(ex::T, d::CMapBasicBasic) where T<:SymbolicType
2526
s = Basic()
26-
ccall((:basic_subs, libsymengine), Nothing, (Ref{Basic}, Ref{Basic}, Ptr{Cvoid}), s, ex, d.ptr)
27+
err_code = ccall((:basic_subs, libsymengine), Cuint, (Ref{Basic}, Ref{Basic}, Ptr{Cvoid}), s, ex, d.ptr)
28+
throw_if_error(err_code, ex)
2729
return s
2830
end
2931

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,3 +245,4 @@ end
245245
@test_throws DomainError exp(zoo)
246246
@test_throws DomainError sin(zoo)
247247
@test_throws DomainError sin(oo)
248+
@test_throws DomainError subs(sin(log(y - y/x)), x => 1)

0 commit comments

Comments
 (0)