mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Don't panic on short input. (#5939)
Fixes #5935 Signed-off-by: Brian Brazil <brian.brazil@robustperception.io>
This commit is contained in:
parent
7d43feb03f
commit
c66bfce8cf
|
@ -44,7 +44,10 @@ func (l *openMetricsLexer) buf() []byte {
|
|||
}
|
||||
|
||||
func (l *openMetricsLexer) cur() byte {
|
||||
return l.b[l.i]
|
||||
if l.i < len(l.b) {
|
||||
return l.b[l.i]
|
||||
}
|
||||
return byte(' ')
|
||||
}
|
||||
|
||||
// next advances the openMetricsLexer to the next character.
|
||||
|
|
|
@ -419,6 +419,14 @@ func TestOMNullByteHandling(t *testing.T) {
|
|||
input: "a\x00{b=\"ddd\"} 1",
|
||||
err: "expected value after metric, got \"MNAME\"",
|
||||
},
|
||||
{
|
||||
input: "#",
|
||||
err: "\"INVALID\" \" \" is not a valid start token",
|
||||
},
|
||||
{
|
||||
input: "# H",
|
||||
err: "\"INVALID\" \" \" is not a valid start token",
|
||||
},
|
||||
}
|
||||
|
||||
for i, c := range cases {
|
||||
|
|
Loading…
Reference in a new issue