Fix data corruption in endcoding/cbor

This commit is contained in:
Mustafa Furkan Bulut
2026-07-05 15:58:45 +03:00
committed by GitHub
parent 5b54b5df31
commit 2c85085fc6

View File

@@ -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)
}
}