refactor: make the panic in fmt explicit to avoid UB
This commit is contained in:
parent
46e7709232
commit
e444415cd9
1 changed files with 1 additions and 1 deletions
|
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue