Commit a6c1524
committed
qcow-stream-tool: Use tail-recursive List.rev_map in read_headers
Otherwise we overflow the stack on large QCOW files:
qcow-stream-tool: internal error, uncaught exception:
Stack overflow
Raised by primitive operation at Dune__exe__Qcow_stream_tool.Impl.read_headers.(fun) in file "ocaml/qcow-stream-tool/qcow_stream_tool.ml", line 23, characters 12-24
Called from Stdlib__List.map in file "list.ml", line 92, characters 32-39
Called from Stdlib__List.map in file "list.ml", line 92, characters 32-39
....
List.rev + List.rev_map is not terribly efficient, but more efficient than
reverting back to handling the QCOW file as raw without knowing which clusters
are allocated.
Signed-off-by: Andrii Sultanov <[email protected]>1 parent 1b75c36 commit a6c1524
1 file changed
+10
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
24 | 27 | | |
25 | | - | |
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
| |||
0 commit comments