Skip to content

Commit

Permalink
Add test for #11540
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Dec 14, 2023
1 parent e95caf6 commit 3a32a6a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/testuninitvar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6334,6 +6334,21 @@ class TestUninitVar : public TestFixture {
" if (pwd == NULL) {}\n"
"}");
ASSERT_EQUALS("[test.cpp:15] -> [test.cpp:17]: (warning) Uninitialized variable: pwd\n", errout.str());

valueFlowUninit("size_t Read(unsigned char* buffer, size_t len);\n" // #11540
"void f() {\n"
" const int N = 100;\n"
" uint8_t data[N];\n"
" size_t data_size = 0;\n"
" for (int i = 0; i < 10; i++) {\n"
" if (!data_size)\n"
" data_size = Read(data, N);\n"
" if (!data_size)\n"
" return;\n"
" if (data[0] == 0x47) {}\n"
" }\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}

void valueFlowUninitBreak() { // Do not show duplicate warnings about the same uninitialized value
Expand Down

0 comments on commit 3a32a6a

Please sign in to comment.