Merge pull request #6954 from mfbulut/master

Fix data corruption in endcoding/cbor
This commit is contained in:
Laytan
2026-07-06 14:57:24 +02:00
committed by GitHub

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