mirror of
https://github.com/prometheus/prometheus
synced 2024-12-24 15:32:48 +00:00
promql: fuzz test needs symbol table for parser
Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
This commit is contained in:
parent
5f50d974c9
commit
0347148628
@ -20,6 +20,7 @@ import (
|
||||
"errors"
|
||||
"io"
|
||||
|
||||
"github.com/prometheus/prometheus/model/labels"
|
||||
"github.com/prometheus/prometheus/model/textparse"
|
||||
"github.com/prometheus/prometheus/promql/parser"
|
||||
)
|
||||
@ -56,8 +57,11 @@ const (
|
||||
maxInputSize = 10240
|
||||
)
|
||||
|
||||
// Use package-scope symbol table to avoid memory allocation on every fuzzing operation.
|
||||
var symbolTable = labels.NewSymbolTable()
|
||||
|
||||
func fuzzParseMetricWithContentType(in []byte, contentType string) int {
|
||||
p, warning := textparse.New(in, contentType, false)
|
||||
p, warning := textparse.New(in, contentType, false, symbolTable)
|
||||
if warning != nil {
|
||||
// An invalid content type is being passed, which should not happen
|
||||
// in this context.
|
||||
|
Loading…
Reference in New Issue
Block a user