diff options
| author | Emilio Jesus Gallego Arias | 2020-04-28 21:32:13 +0200 |
|---|---|---|
| committer | Emilio Jesus Gallego Arias | 2020-04-28 21:32:13 +0200 |
| commit | bcf20edceb3d3a056664f1183fe5b7a5e54408ab (patch) | |
| tree | 905aed27243bee8a4f033f56ac582a3ed6f97d1f | |
| parent | 0e46754c30573206299c0ef2cbf2289a592bbcda (diff) | |
| parent | 1f33314961ad955e6ed5314a499089f3138dfe69 (diff) | |
Merge PR #12193: Close files in fetch_delayed
Ack-by: ejgallego
Ack-by: ppedrot
| -rw-r--r-- | vernac/library.ml | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/vernac/library.ml b/vernac/library.ml index afadbd704d..85db501e84 100644 --- a/vernac/library.ml +++ b/vernac/library.ml @@ -57,14 +57,18 @@ let in_delayed f ch ~segment = let fetch_delayed del = let { del_digest = digest; del_file = f; del_off = pos; } = del in - try - let ch = open_in_bin f in - let () = LargeFile.seek_in ch pos in - let obj = System.marshal_in f ch in - let digest' = Digest.input ch in - if not (String.equal digest digest') then raise (Faulty f); - obj - with e when CErrors.noncritical e -> raise (Faulty f) + let ch = open_in_bin f in + let obj, digest' = + try + let () = LargeFile.seek_in ch pos in + let obj = System.marshal_in f ch in + let digest' = Digest.input ch in + obj, digest' + with e -> close_in ch; raise e + in + close_in ch; + if not (String.equal digest digest') then raise (Faulty f); + obj end @@ -200,7 +204,7 @@ let access_table what tables dp i = with Faulty f -> user_err ~hdr:"Library.access_table" (str "The file " ++ str f ++ str " (bound to " ++ str dir_path ++ - str ") is inaccessible or corrupted,\ncannot load some " ++ + str ") is corrupted,\ncannot load some " ++ str what ++ str " in it.\n") in tables := DPmap.add dp (Fetched t) !tables; |
