Skip to content

Commit

Permalink
Fix Issue #169 SparseMatrixCSC illegal buffers (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkitti authored Dec 15, 2021
1 parent 82c289b commit 50b1230
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/MAT_v5.jl
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,19 @@ function read_sparse(f::IO, swap_bytes::Bool, dimensions::Vector{Int32}, flags::
pr = complex_array(pr, read_data(f, swap_bytes))
end
end

if length(ir) > length(pr)
# Fix for Issue #169, xref https://github.com/JuliaLang/julia/pull/40523
#=
# The following expression must be obeyed according to
# https://github.com/JuliaLang/julia/blob/b3e4341d43da32f4ab6087230d98d00b89c8c004/stdlib/SparseArrays/src/sparsematrix.jl#L86-L90
@debug "SparseMatrixCSC" m n jc ir pr
@debug "SparseMatrixCSC check " length(jc) n+1 jc[end]-1 length(ir) length(pr) begin
length(jc) == n + 1 && jc[end] - 1 == length(ir) == length(pr)
end
=#
# Truncate rowvals (ir) to the be the same length as the non-zero elements (pr)
resize!(ir, length(pr))
end
SparseMatrixCSC(m, n, jc, ir, pr)
end

Expand Down

0 comments on commit 50b1230

Please sign in to comment.