| Anonymous | Login | Signup for a new account | 2013-05-20 19:10 CEST | ![]() |
| Main | My View | View Issues | Change Log | Roadmap |
| View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | |||||||
| ID | Project | Category | View Status | Date Submitted | Last Update | |||
| 0005004 | OCaml | OCaml general | public | 2010-03-18 07:43 | 2010-03-28 10:17 | |||
| Reporter | myst | |||||||
| Assigned To | ||||||||
| Priority | normal | Severity | minor | Reproducibility | always | |||
| Status | closed | Resolution | fixed | |||||
| Platform | OS | OS Version | ||||||
| Product Version | 3.11.1 | |||||||
| Target Version | Fixed in Version | 3.12.0+dev | ||||||
| Summary | 0005004: Buffer.add_channel hangs | |||||||
| Description | I am trying to read whole file by doing: let read_file_bin name = let ic = open_in_bin name in let b = Buffer.create 1024 in (try Buffer.add_channel b ic max_int with _ -> ()); (* <-- HERE *) close_in ic; Array.init (Buffer.length b) (fun i -> int_of_char (Buffer.nth b i)) but it hangs on the line marked. The problem is max_int and the fact that Buffer.add_channel and Buffer.resize do not check for this possibility: let add_channel b ic len = if b.position + len > b.length then resize b len; really_input ic b.buffer b.position len; b.position <- b.position + len Something like the following would be better: let add_channel b ic len = if len < 0 || len > Sys.max_string_length then invalid_arg "Buffer.add_channel"; ... | |||||||
| Tags | No tags attached. | |||||||
| Attached Files | ||||||||
Issue History |
|||
| Date Modified | Username | Field | Change |
| 2010-03-18 07:43 | myst | New Issue | |
| 2010-03-28 10:17 | xleroy | Note Added: 0005274 | |
| 2010-03-28 10:17 | xleroy | Status | new => closed |
| 2010-03-28 10:17 | xleroy | Resolution | open => fixed |
| 2010-03-28 10:17 | xleroy | Fixed in Version | => 3.12.0+dev |
| Copyright © 2000 - 2011 MantisBT Group |