Skip to content

Panic with invalid input #163

Closed
Closed
@johejo

Description

@johejo

how to reproduce

package expr_test

import (
	"testing"

	"github.com/antonmedv/expr"
)

func TestPanic(t *testing.T) {
	const input = "4..0"
	_, err := expr.Compile(input)
	t.Log(err)
}
$ go test . -run TestPanic -v
=== RUN   TestPanic
--- FAIL: TestPanic (0.00s)
panic: runtime error: makeslice: len out of range [recovered]
        panic: runtime error: makeslice: len out of range

goroutine 6 [running]:
testing.tRunner.func1.1(0x6bf8e0, 0x766dc0)
        /home/linuxbrew/.linuxbrew/Cellar/go/1.15.7_1/libexec/src/testing/testing.go:1072 +0x30d
testing.tRunner.func1(0xc000001b00)
        /home/linuxbrew/.linuxbrew/Cellar/go/1.15.7_1/libexec/src/testing/testing.go:1075 +0x41a
panic(0x6bf8e0, 0x766dc0)
        /home/linuxbrew/.linuxbrew/Cellar/go/1.15.7_1/libexec/src/runtime/panic.go:969 +0x1b9
github.com/antonmedv/expr/optimizer.(*constRange).Exit(0x1326408, 0xc00000e480)
        /home/heijo/ghq/github.com/antonmedv/expr/optimizer/const_range.go:22 +0xe5
github.com/antonmedv/expr/ast.(*walker).walk(0xc000073e78, 0xc00000e480)
        /home/heijo/ghq/github.com/antonmedv/expr/ast/visitor.go:45 +0x4be
github.com/antonmedv/expr/ast.Walk(...)
        /home/heijo/ghq/github.com/antonmedv/expr/ast/visitor.go:18
github.com/antonmedv/expr/optimizer.Optimize(0xc00000e480, 0xc000032180, 0x7724e0, 0x6a6620)
        /home/heijo/ghq/github.com/antonmedv/expr/optimizer/optimizer.go:35 +0x268
github.com/antonmedv/expr.Compile(0x70175f, 0x4, 0x0, 0x0, 0x0, 0xc000062770, 0x48ff46, 0x602a76d2)
        /home/heijo/ghq/github.com/antonmedv/expr/expr.go:167 +0x291
github.com/antonmedv/expr_test.TestPanic(0xc000001b00)
        /home/heijo/ghq/github.com/antonmedv/expr/panic_test.go:11 +0x4b
testing.tRunner(0xc000001b00, 0x72ea38)
        /home/linuxbrew/.linuxbrew/Cellar/go/1.15.7_1/libexec/src/testing/testing.go:1123 +0xef
created by testing.(*T).Run
        /home/linuxbrew/.linuxbrew/Cellar/go/1.15.7_1/libexec/src/testing/testing.go:1168 +0x2b3
FAIL    github.com/antonmedv/expr       0.004s
FAIL

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions