From df57a68b47c0493c9b2668d8035083784ef72f64 Mon Sep 17 00:00:00 2001 From: Ted Yu Date: Fri, 22 May 2020 13:35:25 -0700 Subject: [PATCH] Check events against nil Signed-off-by: Ted Yu --- etcdserver/api/v2v3/watcher.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/etcdserver/api/v2v3/watcher.go b/etcdserver/api/v2v3/watcher.go index b17ffa42783..201fb783e51 100644 --- a/etcdserver/api/v2v3/watcher.go +++ b/etcdserver/api/v2v3/watcher.go @@ -97,13 +97,15 @@ func (s *v2v3Store) mkV2Events(wr clientv3.WatchResponse) (evs []*v2store.Event) key = ev } } - v2ev := &v2store.Event{ - Action: string(act.Kv.Value), - Node: s.mkV2Node(key.Kv), - PrevNode: s.mkV2Node(key.PrevKv), - EtcdIndex: mkV2Rev(wr.Header.Revision), + if act != nil && act.Kv != nil && key != nil { + v2ev := &v2store.Event{ + Action: string(act.Kv.Value), + Node: s.mkV2Node(key.Kv), + PrevNode: s.mkV2Node(key.PrevKv), + EtcdIndex: mkV2Rev(wr.Header.Revision), + } + evs = append(evs, v2ev) } - evs = append(evs, v2ev) } return evs }