summaryrefslogtreecommitdiff
path: root/decode.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@datawire.io>2022-08-16 22:40:19 -0600
committerLuke Shumaker <lukeshu@datawire.io>2022-08-17 00:12:35 -0600
commite57bee02e02b7e3697d6c3cb8b75923a92100427 (patch)
treef32610f2b73fbea1f2a94e108fabca18d31d5d27 /decode.go
parent87b02577e50b76d373e3c6b921d776e39cb83346 (diff)
Add tests for decode reading too far
Diffstat (limited to 'decode.go')
-rw-r--r--decode.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/decode.go b/decode.go
index e42c115..a17a572 100644
--- a/decode.go
+++ b/decode.go
@@ -114,7 +114,10 @@ func (dec *Decoder) stackName() string {
return strings.Join(fields, ".")
}
-func Decode(r io.Reader, ptr any) error {
+func Decode(r interface {
+ io.Reader
+ io.RuneScanner // enforce that the reader have .UnreadRune() so that we don't risk reading too far when decoding a number
+}, ptr any) error {
return NewDecoder(r).Decode(ptr)
}