From 2c85085fc66206774c1ef91a820c0c1d2158e0e7 Mon Sep 17 00:00:00 2001 From: Mustafa Furkan Bulut <51883559+mfbulut@users.noreply.github.com> Date: Sun, 5 Jul 2026 15:58:45 +0300 Subject: [PATCH] Fix data corruption in endcoding/cbor --- core/encoding/cbor/coding.odin | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/encoding/cbor/coding.odin b/core/encoding/cbor/coding.odin index bfeb147c4..537368cf4 100644 --- a/core/encoding/cbor/coding.odin +++ b/core/encoding/cbor/coding.odin @@ -411,12 +411,13 @@ _decode_bytes :: proc(d: Decoder, add: Add, type: Major = .Bytes, allocator := c io.copy_n(buf_stream, d.reader, i64(n)) or_return } - v = buf.buf[:] - // Write zero byte so this can be converted to cstring. strings.write_byte(&buf, 0) if .Shrink_Excess in d.flags { shrink(&buf.buf) } + + v = buf.buf[:len(buf.buf)-1] + return } @@ -884,4 +885,4 @@ _encode_deterministic_f64 :: proc(w: io.Writer, v: f64) -> io.Error { } return _encode_f64_exact(w, v) -} \ No newline at end of file +}