Skip to content

Commit 8bff452

Browse files
authored
Fix 10599: regression- segmentation fault on template code (#3565)
1 parent 4f9a563 commit 8bff452

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

lib/checkbufferoverrun.cpp

100644100755
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,8 @@ void CheckBufferOverrun::objectIndex()
999999
if (v.lifetimeKind != ValueFlow::Value::LifetimeKind::Address)
10001000
continue;
10011001
const Variable *var = v.tokvalue->variable();
1002+
if (!var)
1003+
continue;
10021004
if (var->isReference())
10031005
continue;
10041006
if (var->isRValueReference())

test/testbufferoverrun.cpp

100644100755
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4750,6 +4750,15 @@ class TestBufferOverrun : public TestFixture {
47504750
" free(*str);\n"
47514751
"}\n", "test.c");
47524752
ASSERT_EQUALS("", errout.str());
4753+
4754+
check("template <typename T, unsigned N>\n"
4755+
"using vector = Eigen::Matrix<T, N, 1>;\n"
4756+
"template <typename V>\n"
4757+
"void scharr(image2d<vector<V, 2>>& out) {\n"
4758+
" vector<V, 2>* out_row = &out(r, 0);\n"
4759+
" out_row[c] = vector<V, 2>(1,2);\n"
4760+
"}\n");
4761+
ASSERT_EQUALS("", errout.str());
47534762
}
47544763
};
47554764

0 commit comments

Comments
 (0)