refactor: make the panic in fmt explicit to avoid UB

This commit is contained in:
CJ van den Berg 2026-03-12 21:43:47 +01:00
parent 46e7709232
commit e444415cd9
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -297,7 +297,7 @@ pub fn writeValue(writer: *Io.Writer, value: anytype) Io.Writer.Error!void {
pub fn fmt(buf: []u8, value: anytype) []const u8 { pub fn fmt(buf: []u8, value: anytype) []const u8 {
var writer: Io.Writer = .fixed(buf); var writer: Io.Writer = .fixed(buf);
writeValue(&writer, value) catch unreachable; writeValue(&writer, value) catch @panic("cbor.fmt: buffer too small");
return writer.buffered(); return writer.buffered();
} }