Skip to content

Commit 3b2ca3c

Browse files
authored
[Fix] Stackoverflow in BlockSparseArray constructor with wrong number of axes (#109)
1 parent 3ba5eca commit 3b2ca3c

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "BlockSparseArrays"
22
uuid = "2c9a651f-6452-4ace-a6ac-809f4280fbb4"
33
authors = ["ITensor developers <[email protected]> and contributors"]
4-
version = "0.4.5"
4+
version = "0.4.6"
55

66
[deps]
77
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"

src/blocksparsearray/blocksparsearray.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ function BlockSparseArray{T,N,A}(
157157
::UndefInitializer,
158158
dims::Tuple{AbstractVector{<:Integer},Vararg{AbstractVector{<:Integer}}},
159159
) where {T,N,A<:AbstractArray{T,N}}
160+
length(dims) == N ||
161+
throw(ArgumentError("Length of dims doesn't match number of dimensions."))
160162
return BlockSparseArray{T,N,A}(undef, blockedrange.(dims))
161163
end
162164

test/test_basics.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ arrayts = (Array, JLArray)
9797
@test iszero(blockstoredlength(a))
9898
@test iszero(storedlength(a))
9999
end
100+
T != BlockSparseArray{elt} && @test_throws ArgumentError T(undef, bs[1:1])
100101
end
101102

102103
# BlockSparseVector

0 commit comments

Comments
 (0)