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 double-free on ternary operator parsing error #847
Fix double-free on ternary operator parsing error #847
Conversation
good catch, thanks! |
The false branch does get parsed, this needs to be fixed as well. |
Oh, right, got mixed up trying various different things. With eg bare words (which is where I spotted this) both the true and false clauses report the error, but with unexpected end of expression the error message is missing (but it returns with exit code 1). I'll fix the test + commit message... |
v1 gets double-freed when there's an error parsing the result side of the ternary operator. Add testcases to go.
7ec004c
to
203a47d
Compare
I think we just need a
in doPrimary()'s default case to fix missing error for |
That'd work, but then we have inconsistent error messages depending on which branch the error is in:
It also causes a duplicate error at least in the bareword case:
Adding TOK_TERNARY_ALT as a fallthrough case to TOK_EOF in doPrimary() seems to work but didn't actually think about it so dunno if there would be other side-effects. |
The duplicate error is because rpmExprStr/rpmExprBool ignore the return value of the It's not really about TOK_TERNARY_ALT, you'll get the same error with If the different error message bothers you, just delete the TOK_EOF case so that you'll |
Added the rdToken() checks + the generic syntax error. Inconsistent error is much better than no error message at all... |
v1 gets double-freed when there's an error parsing the result side
of the ternary operator. Add testcases to go, one that catches the
actual error and another which serves to demonstrate that the false
branch doesn't get parsed at all, errors or no.