Skip to content

Commit a4d9639

Browse files
committed
fix twine: buf in finalize
1 parent 4b13574 commit a4d9639

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/twine/encode.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ module To_buf : sig
7474
val write_float : t -> float -> buf_offset
7575
val write_string_slice : t -> slice -> buf_offset
7676
val write_blob_slice : t -> slice -> buf_offset
77-
val write_cstor0 : t -> index:offset -> buf_offset
77+
val write_cstor0 : t -> index:int -> buf_offset
7878
end = struct
7979
type buf_offset = offset
8080

@@ -293,10 +293,10 @@ let cstor (self : t) ~(index : int) (args : immediate array) : immediate =
293293
let finalize (self : t) ~(entrypoint : immediate) : slice =
294294
let top = write_or_ref_immediate self entrypoint in
295295

296-
let total_len = self.global_offset + self.buf.len in
297-
assert (top < total_len);
296+
assert (top < self.global_offset + self.buf.len);
298297

299298
let rec finalize_offset top =
299+
let total_len = self.global_offset + self.buf.len in
300300
let delta = total_len - top - 1 in
301301
if delta > 250 then (
302302
(* go through intermediate pointer (uncommon, can happen if last value is ginormous) *)

0 commit comments

Comments
 (0)