* Fix #9217 (Regression: Memory explodes in simplifyTemplateAliases) * fix use after free when nothing was copied
This commit is contained in:
parent
3e5f07b3fb
commit
5ad5cfcc29
|
@ -1317,8 +1317,11 @@ void TemplateSimplifier::simplifyTemplateAliases()
|
|||
const unsigned int argnr = aliasParameterNames[tok1->str()];
|
||||
const Token * const fromStart = args[argnr].first;
|
||||
const Token * const fromEnd = args[argnr].second->previous();
|
||||
TokenList::copyTokens(tok1, fromStart, fromEnd, true);
|
||||
Token *temp = TokenList::copyTokens(tok1, fromStart, fromEnd, true);
|
||||
const bool tempOK(temp && temp != tok1->next());
|
||||
tok1->deleteThis();
|
||||
if (tempOK)
|
||||
tok1 = temp; // skip over inserted parameters
|
||||
} else if (tok1->str() == "typename")
|
||||
tok1->deleteThis();
|
||||
}
|
||||
|
|
|
@ -163,6 +163,7 @@ private:
|
|||
TEST_CASE(template123); // #9183
|
||||
TEST_CASE(template124); // #9197
|
||||
TEST_CASE(template125);
|
||||
TEST_CASE(template126); // #9217
|
||||
TEST_CASE(template_specialization_1); // #7868 - template specialization template <typename T> struct S<C<T>> {..};
|
||||
TEST_CASE(template_specialization_2); // #7868 - template specialization template <typename T> struct S<C<T>> {..};
|
||||
TEST_CASE(template_enum); // #6299 Syntax error in complex enum declaration (including template)
|
||||
|
@ -2935,6 +2936,13 @@ private:
|
|||
"}"), InternalError);
|
||||
}
|
||||
|
||||
void template126() { // #9217
|
||||
const char code[] = "template <typename b> using d = a<b>;\n"
|
||||
"static_assert(i<d<l<b>>>{}, \"\");";
|
||||
const char exp[] = "static_assert ( i < a < l < b > > > { } , \"\" ) ;";
|
||||
ASSERT_EQUALS(exp, tok(code));
|
||||
}
|
||||
|
||||
void template_specialization_1() { // #7868 - template specialization template <typename T> struct S<C<T>> {..};
|
||||
const char code[] = "template <typename T> struct C {};\n"
|
||||
"template <typename T> struct S {a};\n"
|
||||
|
|
Loading…
Reference in New Issue