File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ rules :
2+ - id : batio-to_input_channel
3+ pattern : BatIO.to_input_channel
4+ message : don't use (leaks two file descriptors)
5+ languages : [ocaml]
6+ severity : ERROR
Original file line number Diff line number Diff line change @@ -415,7 +415,14 @@ struct
415415 in
416416 match file with
417417 | Some fn ->
418- let v = Yojson.Safe. from_channel % BatIO. to_input_channel |> File. with_file_in (Fpath. to_string fn) in
418+ let v =
419+ let ic = Stdlib. open_in (Fpath. to_string fn) in
420+ Fun. protect ~finally: (fun () ->
421+ Stdlib. close_in ic
422+ ) (fun () ->
423+ Yojson.Safe. from_channel ic
424+ )
425+ in
419426 merge v;
420427 if Goblint_tracing. tracing then Goblint_tracing. trace " conf" " Merging with '%a', resulting\n %a." GobFpath. pretty fn GobYojson. pretty ! json_conf
421428 | None -> raise (Sys_error (Printf. sprintf " %s: No such file or directory" (Fpath. to_string fn)))
You can’t perform that action at this time.
0 commit comments