File tree 1 file changed +6
-3
lines changed
1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -303,9 +303,9 @@ func (b *Builder) add(bytes ...byte) {
303
303
b .result = append (b .result , bytes ... )
304
304
}
305
305
306
- // Unwrite rolls back n bytes written directly to the Builder. An attempt by a
307
- // child builder passed to a continuation to unwrite bytes from its parent will
308
- // panic.
306
+ // Unwrite rolls back non-negative n bytes written directly to the Builder.
307
+ // An attempt by a child builder passed to a continuation to unwrite bytes
308
+ // from its parent will panic.
309
309
func (b * Builder ) Unwrite (n int ) {
310
310
if b .err != nil {
311
311
return
@@ -317,6 +317,9 @@ func (b *Builder) Unwrite(n int) {
317
317
if length < 0 {
318
318
panic ("cryptobyte: internal error" )
319
319
}
320
+ if n < 0 {
321
+ panic ("cryptobyte: attempted to unwrite negative number of bytes" )
322
+ }
320
323
if n > length {
321
324
panic ("cryptobyte: attempted to unwrite more than was written" )
322
325
}
You can’t perform that action at this time.
0 commit comments