diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 0371d4649..03a398fb5 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -1324,7 +1324,7 @@ bool SymbolDatabase::arrayDimensions(std::vector &dimensions, const T const Token *dim = tok; - while (dim && dim->next() && dim->str() == "[" && dim->next()->str() != "]") + while (dim && dim->next() && dim->str() == "[") { Dimension dimension; dimension.num = 0; diff --git a/test/testbufferoverrun.cpp b/test/testbufferoverrun.cpp index beb72c4e0..2f26daa79 100644 --- a/test/testbufferoverrun.cpp +++ b/test/testbufferoverrun.cpp @@ -108,6 +108,7 @@ private: TEST_CASE(array_index_30); // ticket #2086 - out of bounds when type is unknown TEST_CASE(array_index_31); // ticket #2120 - out of bounds in subfunction when type is unknown TEST_CASE(array_index_32); + TEST_CASE(array_index_33); // ticket #3044 TEST_CASE(array_index_multidim); TEST_CASE(array_index_switch_in_for); TEST_CASE(array_index_for_in_for); // FP: #2634 @@ -1080,6 +1081,14 @@ private: TODO_ASSERT_EQUALS("[test.cpp:7]: (error) Array 'm_x[1]' index 1 out of bounds\n","", errout.str()); } + void array_index_33() + { + check("void foo(char bar[][4]) {\n" + " baz(bar[5]);\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + } + void array_index_multidim() { check("void f()\n"