Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix pop panic when length is 0 #44

Merged
merged 1 commit into from
Jul 23, 2021

Conversation

tjblackheart
Copy link
Contributor

@tjblackheart tjblackheart commented Jul 23, 2021

Hi,

on rare occasions (not sure why - I cannot really create a working failed state, as this happens at random) the twig autoEscapeVisitor is empty and throws a panic when pop() is called. Looks like this:

http: panic serving 172.17.0.1:42832: runtime error: slice bounds out of range [:-1]
goroutine 10919 [running]:
net/http.(*conn).serve.func1(0xc000443360)
	/usr/local/go/src/net/http/server.go:1804 +0x153
panic(0xa1d120, 0xc00038e978)
	/usr/local/go/src/runtime/panic.go:971 +0x499
github.com/tyler-sommer/stick/twig.(*autoEscapeVisitor).pop(...)
	/go/pkg/mod/github.com/tyler-sommer/stick@v1.0.3/twig/escape.go:73
github.com/tyler-sommer/stick/twig.(*autoEscapeVisitor).Leave(0xc0000a2750, 0xaf2290, 0xc0001cb960)
	/go/pkg/mod/github.com/tyler-sommer/stick@v1.0.3/twig/escape.go:105 +0x7
...

This PR should take care of that.

@tyler-sommer tyler-sommer merged commit 6fc253b into tyler-sommer:master Jul 23, 2021
@tyler-sommer
Copy link
Owner

It sounds like maybe entering/leaving is unbalanced somewhere but this should be an acceptable workaround. Thanks for the PR!

@tjblackheart tjblackheart deleted the fix/stack-pop-panic branch July 27, 2021 20:45
@fsmiamoto fsmiamoto mentioned this pull request Jan 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants