Przeglądaj źródła

Merge pull request #256 from sb-akd/v2

encoder.marshal panics on nil pointers
Roger Peppe 8 lat temu
rodzic
commit
3c68098bff
1 zmienionych plików z 1 dodań i 1 usunięć
  1. 1 1
      encode.go

+ 1 - 1
encode.go

@@ -83,7 +83,7 @@ func (e *encoder) marshalDoc(tag string, in reflect.Value) {
 }
 }
 
 
 func (e *encoder) marshal(tag string, in reflect.Value) {
 func (e *encoder) marshal(tag string, in reflect.Value) {
-	if !in.IsValid() {
+	if !in.IsValid() || in.Kind() == reflect.Ptr && in.IsNil() {
 		e.nilv()
 		e.nilv()
 		return
 		return
 	}
 	}