Skip to content

Commit 7515305

Browse files
Add test for #10413 (#4687)
1 parent 0b62c73 commit 7515305

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

test/testbufferoverrun.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1724,7 +1724,7 @@ class TestBufferOverrun : public TestFixture {
17241724
errout.str());
17251725
}
17261726

1727-
void array_index_59()
1727+
void array_index_59() // #10413
17281728
{
17291729
check("long f(long b) {\n"
17301730
" const long a[] = { 0, 1, };\n"
@@ -1734,6 +1734,22 @@ class TestBufferOverrun : public TestFixture {
17341734
" return a[b];\n"
17351735
"}\n");
17361736
ASSERT_EQUALS("", errout.str());
1737+
1738+
check("void f(int a, int b) {\n"
1739+
" const int S[2] = {};\n"
1740+
" if (a < 0) {}\n"
1741+
" else {\n"
1742+
" if (b < 0) {}\n"
1743+
" else if (S[b] > S[a]) {}\n"
1744+
" }\n"
1745+
"}\n");
1746+
ASSERT_EQUALS("", errout.str());
1747+
1748+
check("int a[2] = {};\n"
1749+
"void f(int i) {\n"
1750+
" g(i < 0 ? 0 : a[i]);\n"
1751+
"}\n");
1752+
ASSERT_EQUALS("", errout.str());
17371753
}
17381754

17391755
void array_index_60()

test/testnullpointer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2790,7 +2790,7 @@ class TestNullPointer : public TestFixture {
27902790
"struct D : public B { int f() override; };\n"
27912791
"int g(B* p) {\n"
27922792
" if (p) {\n"
2793-
" auto d = dynamic_cast<B*>(p);\n"
2793+
" auto d = dynamic_cast<D*>(p);\n"
27942794
" return d ? d->f() : 0;\n"
27952795
" }\n"
27962796
" return 0;\n"

0 commit comments

Comments
 (0)