From 4d58d9fc87d8d0bf96c530d1fa495d94c4a11644 Mon Sep 17 00:00:00 2001 From: IOBYTE Date: Sun, 9 Feb 2020 05:19:36 -0500 Subject: [PATCH] fix daca chromium crash (#2527) --- lib/templatesimplifier.cpp | 5 ++++- test/testsimplifytemplate.cpp | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index 90103974d..42b2d66fb 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -1238,8 +1238,11 @@ void TemplateSimplifier::simplifyTemplateAliases() while (tok2 && !Token::Match(tok2, "[,>;{}]")) { if (tok2->link() && Token::Match(tok2, "(|[")) tok2 = tok2->link(); - else if (tok2->str() == "<") + else if (tok2->str() == "<") { tok2 = tok2->findClosingBracket(); + if (!tok2) + break; + } tok2 = tok2->next(); } diff --git a/test/testsimplifytemplate.cpp b/test/testsimplifytemplate.cpp index 09f4aacbb..cde08b091 100644 --- a/test/testsimplifytemplate.cpp +++ b/test/testsimplifytemplate.cpp @@ -193,6 +193,7 @@ private: TEST_CASE(template153); // #9483 TEST_CASE(template154); // #9495 TEST_CASE(template155); // #9539 + TEST_CASE(template156); TEST_CASE(template_specialization_1); // #7868 - template specialization template struct S> {..}; TEST_CASE(template_specialization_2); // #7868 - template specialization template struct S> {..}; TEST_CASE(template_enum); // #6299 Syntax error in complex enum declaration (including template) @@ -3712,6 +3713,20 @@ private: ASSERT_EQUALS(exp, tok(code)); } + void template156() { + const char code[] = "template struct c { static constexpr int d = a; };\n" + "template using e = c;\n" + "using f = e;\n" + "template struct g : f {};\n" + "template using h = e::d>;\n" + "template using i = e::d>;\n" + "template using k = e::d>;\n" + "template using l = h::d, e<1 < (j)0>, f>;\n" + "template void m(int, int, int) { l d; }\n" + "void n() { m(0, 4, 5); }"; + tok(code); // don't crash + } + void template_specialization_1() { // #7868 - template specialization template struct S> {..}; const char code[] = "template struct C {};\n" "template struct S {a};\n"