Skip to content

Commit 54ab288

Browse files
Fix boundscheck in datalayouts
1 parent e1ba371 commit 54ab288

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/DataLayouts/DataLayouts.jl

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -356,21 +356,23 @@ end
356356
end
357357

358358
@inline function slab(data::IJFH{S, Nij}, h::Integer) where {S, Nij}
359-
@boundscheck (1 <= h <= length(data)) || throw(BoundsError(data, (h,)))
359+
@boundscheck (1 <= h <= size(parent(data), 4)) ||
360+
throw(BoundsError(data, (h,)))
360361
dataview = @inbounds view(parent(data), :, :, :, h)
361362
IJF{S, Nij}(dataview)
362363
end
363364

364365
@inline function slab(data::IJFH{S, Nij}, v::Integer, h::Integer) where {S, Nij}
365-
@boundscheck (v >= 1 && 1 <= h <= length(data)) ||
366+
@boundscheck (v >= 1 && 1 <= h <= size(parent(data), 4)) ||
366367
throw(BoundsError(data, (v, h)))
367368
dataview = @inbounds view(parent(data), :, :, :, h)
368369
IJF{S, Nij}(dataview)
369370
end
370371

371372
@inline function column(data::IJFH{S, Nij}, i, j, h) where {S, Nij}
372-
@boundscheck (1 <= j <= Nij && 1 <= i <= Nij && 1 <= h <= length(data)) ||
373-
throw(BoundsError(data, (i, j, h)))
373+
@boundscheck (
374+
1 <= j <= Nij && 1 <= i <= Nij && 1 <= h <= size(parent(data), 4)
375+
) || throw(BoundsError(data, (i, j, h)))
374376
dataview = @inbounds view(parent(data), i, j, :, h)
375377
DataF{S}(dataview)
376378
end
@@ -449,14 +451,15 @@ function Base.fill!(data::IFH, val)
449451
end
450452

451453
@inline function slab(data::IFH{S, Ni}, h::Integer) where {S, Ni}
452-
@boundscheck (1 <= h <= length(data)) || throw(BoundsError(data, (h,)))
454+
@boundscheck (1 <= h <= size(parent(data), 3)) ||
455+
throw(BoundsError(data, (h,)))
453456
dataview = @inbounds view(parent(data), :, :, h)
454457
IF{S, Ni}(dataview)
455458
end
456459
Base.@propagate_inbounds slab(data::IFH, v::Integer, h::Integer) = slab(data, h)
457460

458461
@inline function column(data::IFH{S, Ni}, i, h) where {S, Ni}
459-
@boundscheck (1 <= h <= length(data) && 1 <= i <= Ni) ||
462+
@boundscheck (1 <= h <= size(parent(data), 3) && 1 <= i <= Ni) ||
460463
throw(BoundsError(data, (i, h)))
461464
dataview = @inbounds view(parent(data), i, :, h)
462465
DataF{S}(dataview)
@@ -969,7 +972,7 @@ end
969972
end
970973

971974
@inline function Base.setindex!(data::VF{S}, val, v::Integer) where {S}
972-
@boundscheck (1 <= v <= length(parent(data))) ||
975+
@boundscheck (1 <= v <= size(parent(data), 1)) ||
973976
throw(BoundsError(data, (v,)))
974977
@inbounds set_struct!(
975978
parent(data),

0 commit comments

Comments
 (0)