Skip to content

Commit 5fc8709

Browse files
throw error to prevent segfault from even # of columns
1 parent c7d5bc0 commit 5fc8709

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/libfasttransforms.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,17 @@ function checksize(p::FTPlan{T}, x::Array{T}) where T
136136
end
137137
end
138138

139+
for K in (SPHERE, SPHEREV, DISK)
140+
@eval function checksize(p::FTPlan{T, 2, $K}, x::Matrix{T}) where T
141+
if p.n != size(x, 1)
142+
throw(DimensionMismatch("FTPlan has dimensions $(p.n) × $(p.n), x has leading dimension $(size(x, 1))"))
143+
end
144+
if iseven(size(x, 2))
145+
throw(DimensionMismatch("This FTPlan only operates on arrays with an odd number of columns."))
146+
end
147+
end
148+
end
149+
139150
unsafe_convert(::Type{Ptr{ft_plan_struct}}, p::FTPlan) = p.plan
140151
unsafe_convert(::Type{Ptr{mpfr_t}}, p::FTPlan) = unsafe_convert(Ptr{mpfr_t}, p.plan)
141152

0 commit comments

Comments
 (0)