Skip to content

Commit

Permalink
Fix CFILE use in sparse
Browse files Browse the repository at this point in the history
  • Loading branch information
Keno committed Mar 19, 2015
1 parent 20497c1 commit 0eb1edf
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion base/sparse/cholmod.jl
Expand Up @@ -663,6 +663,13 @@ for Ti in IndexTypes
finalizer(s, free!)
s
end

function read_sparse(file::IO, T)
cfile = Libc.FILE(file)
s = read_sparse(cfile, T)
close(cfile)

This comment has been minimized.

Copy link
@tkelman

tkelman Mar 19, 2015

Contributor

doesn't this need to close(cfile) even if read_sparse(cfile, T) errors ?

This comment has been minimized.

Copy link
@Keno

Keno Mar 19, 2015

Author Member

yes. Thanks!

s
end
end
end

Expand Down Expand Up @@ -791,7 +798,7 @@ Sparse(A::Dense) = dense_to_sparse(A, Cint)
Sparse(L::Factor) = factor_to_sparse!(copy(L))
function Sparse(filename::ByteString)
open(filename) do f
return read_sparse(Libc.FILE(f), SuiteSparse_long)
return read_sparse(f, SuiteSparse_long)
end
end

Expand Down

0 comments on commit 0eb1edf

Please sign in to comment.