summaryrefslogtreecommitdiff
path: root/Source/cmGeneratorExpressionParser.cxx
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2013-08-13 13:32:27 +0200
committerStephen Kelly <steveire@gmail.com>2013-08-13 13:58:39 +0200
commit36eef302c0b8ecb992c5d4b01562bcaef543b6fc (patch)
tree52bf92db14c90c3528f573f68893eee0d85e728f /Source/cmGeneratorExpressionParser.cxx
parent4bc8b7abab976530d9675cff13ef1dc7c2139d00 (diff)
downloadcmake-36eef302c0b8ecb992c5d4b01562bcaef543b6fc.tar.gz
Genex: Fix segfault when parsing ends with parameter expectation.
The extendResult method expects a non-empty parameters vector, as assured by the normal case. Avoid calling the method when the parser finds an incomplete generator expression, but has already entered the state of expecting to find parameters.
Diffstat (limited to 'Source/cmGeneratorExpressionParser.cxx')
-rw-r--r--Source/cmGeneratorExpressionParser.cxx20
1 files changed, 19 insertions, 1 deletions
diff --git a/Source/cmGeneratorExpressionParser.cxx b/Source/cmGeneratorExpressionParser.cxx
index a619cecd08..e1fb8f1def 100644
--- a/Source/cmGeneratorExpressionParser.cxx
+++ b/Source/cmGeneratorExpressionParser.cxx
@@ -126,6 +126,9 @@ void cmGeneratorExpressionParser::ParseGeneratorExpression(
std::vector<std::vector<cmGeneratorExpressionToken>::const_iterator>
commaTokens;
std::vector<cmGeneratorExpressionToken>::const_iterator colonToken;
+
+ bool emptyParamTermination = false;
+
if (this->it != this->Tokens.end() &&
this->it->TokenType == cmGeneratorExpressionToken::ColonSeparator)
{
@@ -133,6 +136,10 @@ void cmGeneratorExpressionParser::ParseGeneratorExpression(
parameters.resize(parameters.size() + 1);
assert(this->it != this->Tokens.end());
++this->it;
+ if(this->it == this->Tokens.end())
+ {
+ emptyParamTermination = true;
+ }
while (this->it != this->Tokens.end() &&
this->it->TokenType == cmGeneratorExpressionToken::CommaSeparator)
@@ -141,6 +148,10 @@ void cmGeneratorExpressionParser::ParseGeneratorExpression(
parameters.resize(parameters.size() + 1);
assert(this->it != this->Tokens.end());
++this->it;
+ if(this->it == this->Tokens.end())
+ {
+ emptyParamTermination = true;
+ }
}
while (this->it != this->Tokens.end() &&
this->it->TokenType == cmGeneratorExpressionToken::ColonSeparator)
@@ -164,6 +175,10 @@ void cmGeneratorExpressionParser::ParseGeneratorExpression(
parameters.resize(parameters.size() + 1);
assert(this->it != this->Tokens.end());
++this->it;
+ if(this->it == this->Tokens.end())
+ {
+ emptyParamTermination = true;
+ }
}
while (this->it != this->Tokens.end() &&
this->it->TokenType == cmGeneratorExpressionToken::ColonSeparator)
@@ -203,7 +218,10 @@ void cmGeneratorExpressionParser::ParseGeneratorExpression(
assert(parameters.size() > commaTokens.size());
for ( ; pit != pend; ++pit, ++commaIt)
{
- extendResult(result, *pit);
+ if (!pit->empty() && !emptyParamTermination)
+ {
+ extendResult(result, *pit);
+ }
if (commaIt != commaTokens.end())
{
extendText(result, *commaIt);