From f80b787de03a9c5b0caae8cb557d199afa2a57b1 Mon Sep 17 00:00:00 2001 From: Travis Date: Mon, 3 Aug 2020 18:00:52 -0500 Subject: [PATCH] safe cast of bool in executeClearRow --- executor.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/executor.go b/executor.go index 25f5c074e..a44606f2d 100644 --- a/executor.go +++ b/executor.go @@ -3074,11 +3074,18 @@ func (e *executor) executeClearRow(ctx context.Context, index string, c *pql.Cal // Merge returned results at coordinating node. reduceFn := func(ctx context.Context, prev, v interface{}) interface{} { - val := v.(bool) - if prev == nil { + val, ok := v.(bool) + if !ok { + return errors.Errorf("executeClearRow.reduceFn: val is non-bool (%+v)", v) + } + if prev == nil || val { return val } - return val || prev.(bool) + pval, ok := prev.(bool) + if !ok { + return errors.Errorf("executeClearRow.reduceFn: prev is non-bool (%+v)", prev) + } + return pval } result, err := e.mapReduce(ctx, index, shards, c, opt, mapFn, reduceFn) @@ -3166,7 +3173,7 @@ func (e *executor) executeSetRow(ctx context.Context, indexName string, c *pql.C if !ok { return errors.Errorf("executeSetRow.reduceFn: val is non-bool (%+v)", v) } - if val { + if prev == nil || val { return val }