Fix 10599: regression- segmentation fault on template code (#3565)

This commit is contained in:
Paul Fultz II 2021-11-15 23:49:13 -06:00 committed by GitHub
parent 4f9a563570
commit 8bff45281d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

2
lib/checkbufferoverrun.cpp Normal file → Executable file
View File

@ -999,6 +999,8 @@ void CheckBufferOverrun::objectIndex()
if (v.lifetimeKind != ValueFlow::Value::LifetimeKind::Address)
continue;
const Variable *var = v.tokvalue->variable();
if (!var)
continue;
if (var->isReference())
continue;
if (var->isRValueReference())

9
test/testbufferoverrun.cpp Normal file → Executable file
View File

@ -4750,6 +4750,15 @@ private:
" free(*str);\n"
"}\n", "test.c");
ASSERT_EQUALS("", errout.str());
check("template <typename T, unsigned N>\n"
"using vector = Eigen::Matrix<T, N, 1>;\n"
"template <typename V>\n"
"void scharr(image2d<vector<V, 2>>& out) {\n"
" vector<V, 2>* out_row = &out(r, 0);\n"
" out_row[c] = vector<V, 2>(1,2);\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
};