Skip to content
This repository was archived by the owner on Dec 15, 2025. It is now read-only.

Commit ddc5af4

Browse files
committed
fix encoding of nil non-empty interface
1 parent 2f7e5c8 commit ddc5af4

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

feature_reflect_native.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,9 +397,11 @@ func (codec *nonEmptyInterfaceCodec) Decode(ptr unsafe.Pointer, iter *Iterator)
397397
func (codec *nonEmptyInterfaceCodec) Encode(ptr unsafe.Pointer, stream *Stream) {
398398
nonEmptyInterface := (*nonEmptyInterface)(ptr)
399399
var i interface{}
400-
e := (*emptyInterface)(unsafe.Pointer(&i))
401-
e.typ = nonEmptyInterface.itab.typ
402-
e.word = nonEmptyInterface.word
400+
if nonEmptyInterface.itab != nil {
401+
e := (*emptyInterface)(unsafe.Pointer(&i))
402+
e.typ = nonEmptyInterface.itab.typ
403+
e.word = nonEmptyInterface.word
404+
}
403405
stream.WriteVal(i)
404406
}
405407

0 commit comments

Comments
 (0)