summaryrefslogtreecommitdiff
path: root/src/core/parser/stack
diff options
context:
space:
mode:
authorAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-04-17 01:20:27 +0200
committerAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2016-04-25 22:26:13 +0200
commit93e69ca433401c0224edc1d23462c3ff2051a82b (patch)
tree53a0a54c9fc2db86c18fac2291f6ca9bc98918bd /src/core/parser/stack
parent0516c20666567049f81d45890e6f25ae0170c84c (diff)
Do not handle tokens if the current handler is not valid.
Fixes crash bug in added integration test.
Diffstat (limited to 'src/core/parser/stack')
-rw-r--r--src/core/parser/stack/Stack.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/core/parser/stack/Stack.cpp b/src/core/parser/stack/Stack.cpp
index 2ad5c8b..2acea32 100644
--- a/src/core/parser/stack/Stack.cpp
+++ b/src/core/parser/stack/Stack.cpp
@@ -692,7 +692,7 @@ ssize_t StackImpl::pendingCloseTokenHandlerIdx(TokenId token) const
TokenSet StackImpl::currentTokens() const
{
TokenSet res;
- if (currentInfo().state().supportsTokens) {
+ if (currentInfo().valid && currentInfo().state().supportsTokens) {
res = tokenStack.tokens();
ssize_t idx = pendingCloseTokenHandlerIdx();
if (idx >= 0) {
@@ -1111,6 +1111,12 @@ bool StackImpl::handleOpenTokens(Logger &logger, const Token &token,
void StackImpl::handleToken(const Token &token)
{
+ // If the current handler is not valid, just ignore the token
+ // TODO: Unify the handling of invalid elements across this class
+ if (!handlersValid()) {
+ return;
+ }
+
// If the token matches one from the "pendingCloseTokens" list, then just
// end the corresponding handler
const ssize_t pendingCloseIndex = pendingCloseTokenHandlerIdx(token.id);