Skip to content

Commit cc35d48

Browse files
authored
Fix possible nil deref in ogre (#1954)
Shouldn't normally happen, but we're also not doing normal things :) Saw this happen in some testing. Signed-off-by: Anders Eknert <anders.eknert@apple.com>
1 parent d0e99b5 commit cc35d48

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

internal/ogre/evaluator.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ func (e *Evaluator) Eval(ctx context.Context) (err error) {
8181
return errNoResultHandler
8282
}
8383

84+
if e.prepared == nil {
85+
return errors.New("query must be prepared before eval")
86+
}
87+
8488
store := e.prepared.store.store
8589
txnProvided := e.txn != nil
8690

internal/ogre/query.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ func (q *Query) Prepare(_ context.Context) (*Query, error) {
118118
q.metrics = metrics.NoOp()
119119
}
120120

121+
if q.store == nil {
122+
q.store = NewStore()
123+
}
124+
121125
// Compile all modules
122126
q.compiler = q.newCompiler()
123127

@@ -135,10 +139,6 @@ func (q *Query) Prepare(_ context.Context) (*Query, error) {
135139
return nil, q.compiler.Errors
136140
}
137141

138-
if q.store == nil {
139-
q.store = NewStore()
140-
}
141-
142142
return q, nil
143143
}
144144

0 commit comments

Comments
 (0)