Skip to content

Commit fc8edd6

Browse files
Merge pull request #995 from sim642/ocaml-5.1-marshal
Fix `Lwt_io.read_value` on OCaml 5.1
2 parents e0ebd72 + 318b0f8 commit fc8edd6

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

CHANGES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737

3838
* Fix race in worker loop. (Thomas Leonard, #993, #994)
3939

40+
* Fix marshall header size in Lwt_io.read_value. (Simmo Saan, #995)
41+
4042

4143
===== 5.6.1 =====
4244

src/unix/lwt_io.ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -842,12 +842,12 @@ struct
842842
Lwt.return (Bytes.unsafe_to_string buf)
843843

844844
let read_value ic =
845-
let header = Bytes.create 20 in
846-
unsafe_read_into_exactly ic header 0 20 >>= fun () ->
845+
let header = Bytes.create Marshal.header_size in
846+
unsafe_read_into_exactly ic header 0 Marshal.header_size >>= fun () ->
847847
let bsize = Marshal.data_size header 0 in
848-
let buffer = Bytes.create (20 + bsize) in
849-
Bytes.unsafe_blit header 0 buffer 0 20;
850-
unsafe_read_into_exactly ic buffer 20 bsize >>= fun () ->
848+
let buffer = Bytes.create (Marshal.header_size + bsize) in
849+
Bytes.unsafe_blit header 0 buffer 0 Marshal.header_size;
850+
unsafe_read_into_exactly ic buffer Marshal.header_size bsize >>= fun () ->
851851
Lwt.return (Marshal.from_bytes buffer 0)
852852

853853
(* +---------------------------------------------------------------+

0 commit comments

Comments
 (0)