Prechádzať zdrojové kódy

fix encoding of nil non-empty interface

Jason Toffaletti 8 rokov pred
rodič
commit
ddc5af4512
1 zmenil súbory, kde vykonal 5 pridanie a 3 odobranie
  1. 5 3
      feature_reflect_native.go

+ 5 - 3
feature_reflect_native.go

@@ -397,9 +397,11 @@ func (codec *nonEmptyInterfaceCodec) Decode(ptr unsafe.Pointer, iter *Iterator)
 func (codec *nonEmptyInterfaceCodec) Encode(ptr unsafe.Pointer, stream *Stream) {
 	nonEmptyInterface := (*nonEmptyInterface)(ptr)
 	var i interface{}
-	e := (*emptyInterface)(unsafe.Pointer(&i))
-	e.typ = nonEmptyInterface.itab.typ
-	e.word = nonEmptyInterface.word
+	if nonEmptyInterface.itab != nil {
+		e := (*emptyInterface)(unsafe.Pointer(&i))
+		e.typ = nonEmptyInterface.itab.typ
+		e.word = nonEmptyInterface.word
+	}
 	stream.WriteVal(i)
 }