Skip to content

Commit

Permalink
Use match exception to avoid try/with context
Browse files Browse the repository at this point in the history
- mitigate stack overflow risk for big files
  • Loading branch information
AllanBlanchard committed Jun 21, 2023
1 parent a3f938b commit 214828d
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/report/html.ml
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,9 @@ let output_for_source_file
let lines, line_count =
let rec read number acc =
let start_ofs = pos_in in_channel in
try
let line = input_line in_channel in
match input_line in_channel with
| exception End_of_file -> List.rev acc, number - 1
| line ->
let end_ofs = pos_in in_channel in
let before, after = Util.split (fun (o, _) -> o < end_ofs) !pts in
pts := after;
Expand All @@ -353,8 +354,6 @@ let output_for_source_file
before
in
read (number + 1) ((number, line', visited, unvisited)::acc)

with End_of_file -> List.rev acc, number - 1
in
read 1 []
in
Expand Down

0 comments on commit 214828d

Please sign in to comment.