Skip to content

Commit

Permalink
fix #28597, error for empty arrays with some negative dim sizes (#28659)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson authored Aug 15, 2018
1 parent 630f53a commit 5c1f6b0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ static jl_array_t *_new_array_(jl_value_t *atype, uint32_t ndims, size_t *dims,
jl_array_t *a;

for(i=0; i < ndims; i++) {
wideint_t prod = (wideint_t)nel * (wideint_t)dims[i];
if (prod > (wideint_t) MAXINTVAL)
size_t di = dims[i];
wideint_t prod = (wideint_t)nel * (wideint_t)di;
if (prod > (wideint_t) MAXINTVAL || di > MAXINTVAL)
jl_error("invalid Array dimensions");
nel = prod;
}
Expand Down
5 changes: 5 additions & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6697,3 +6697,8 @@ function repackage28445()
true
end
@test repackage28445()

# issue #28597
@test_throws ErrorException Array{Int, 2}(undef, 0, -10)
@test_throws ErrorException Array{Int, 2}(undef, -10, 0)
@test_throws ErrorException Array{Int, 2}(undef, -1, -1)

1 comment on commit 5c1f6b0

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

Please sign in to comment.