mirror of
https://github.com/golang/go
synced 2024-11-25 02:07:58 -07:00
gob: fix bug sending zero-length top-level slices and maps
Fixes #1278. R=rsc CC=golang-dev https://golang.org/cl/3434046
This commit is contained in:
parent
062406bc64
commit
b7c73110b1
@ -473,7 +473,7 @@ func (enc *Encoder) encOpFor(rt reflect.Type) (encOp, int) {
|
|||||||
elemOp, indir := enc.encOpFor(t.Elem())
|
elemOp, indir := enc.encOpFor(t.Elem())
|
||||||
op = func(i *encInstr, state *encoderState, p unsafe.Pointer) {
|
op = func(i *encInstr, state *encoderState, p unsafe.Pointer) {
|
||||||
slice := (*reflect.SliceHeader)(p)
|
slice := (*reflect.SliceHeader)(p)
|
||||||
if slice.Len == 0 {
|
if !state.sendZero && slice.Len == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
state.update(i)
|
state.update(i)
|
||||||
@ -495,7 +495,7 @@ func (enc *Encoder) encOpFor(rt reflect.Type) (encOp, int) {
|
|||||||
// the iteration.
|
// the iteration.
|
||||||
v := reflect.NewValue(unsafe.Unreflect(t, unsafe.Pointer((p))))
|
v := reflect.NewValue(unsafe.Unreflect(t, unsafe.Pointer((p))))
|
||||||
mv := reflect.Indirect(v).(*reflect.MapValue)
|
mv := reflect.Indirect(v).(*reflect.MapValue)
|
||||||
if mv.Len() == 0 {
|
if !state.sendZero && mv.Len() == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
state.update(i)
|
state.update(i)
|
||||||
|
Loading…
Reference in New Issue
Block a user