]> Cypherpunks repositories - gostls13.git/commit
encoding/gob: error out instead of panicking on nil dereference
authorEmmanuel Odeke <emm.odeke@gmail.com>
Sun, 17 Jul 2016 21:22:15 +0000 (14:22 -0700)
committerRob Pike <r@golang.org>
Fri, 19 Aug 2016 21:54:39 +0000 (21:54 +0000)
commit0a2a64d85d52ad51de34d39bc5685c39c0e1e32a
treec42b4fe4ab44670f006550aaa27a4aff52910eee
parent14e59511661303ab1406f7c21ee27e58bcd0750e
encoding/gob: error out instead of panicking on nil dereference

Do not panic when we encounter nil interface values which are
invalid values for gob. Previously this wasn't caught yet
we were calling reflect.*.Type() on reflect.Invalid values
thereby causing panic:
  `panic: reflect: call of reflect.Value.Type on zero Value.`
which is a panic not enforced by encoding/gob itself.
We can catch this and send back an error to the caller.

Fixes #16204

Change-Id: Ie646796db297759a74a02eee5267713adbe0c3a0
Reviewed-on: https://go-review.googlesource.com/24989
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Rob Pike <r@golang.org>
src/encoding/gob/encoder.go
src/encoding/gob/encoder_test.go