Merge pull request #638 from travisturner/fix-executeclearrow

safe cast of bool in executeClearRow
This commit is contained in:
Travis Turner 2020-08-04 15:52:48 -05:00 committed by GitHub
commit df709af10e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3301,11 +3301,18 @@ func (e *executor) executeClearRow(ctx context.Context, tx Tx, index string, c *
// 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)
@ -3393,7 +3400,7 @@ func (e *executor) executeSetRow(ctx context.Context, tx Tx, indexName string, c
if !ok {
return errors.Errorf("executeSetRow.reduceFn: val is non-bool (%+v)", v)
}
if val {
if prev == nil || val {
return val
}