FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix #14984: Valueflow: Buffer size not tracked across function calls by ludviggunne · Pull Request #8806 · cppcheck-opensource/cppcheck · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .cpp  (2) .py  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
2 changes: 1 addition & 1 deletion lib/valueflow.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -7541,6 +7541,7 @@ void ValueFlow::setValues(TokenList& tokenlist,
VFA(valueFlowInferCondition(tokenlist, settings)),
VFA(valueFlowSwitchVariable(tokenlist, symboldatabase, errorLogger, settings)),
VFA(valueFlowForLoop(tokenlist, symboldatabase, errorLogger, settings)),
VFA(valueFlowDynamicBufferSize(tokenlist, symboldatabase, errorLogger, settings)),
VFA(valueFlowSubFunction(tokenlist, symboldatabase, errorLogger, settings)),
VFA(valueFlowFunctionReturn(tokenlist, errorLogger, settings)),
VFA(valueFlowLifetime(tokenlist, errorLogger, settings)),
Expand All @@ -7557,7 +7558,6 @@ void ValueFlow::setValues(TokenList& tokenlist,
});

runner.run_once({
VFA(valueFlowDynamicBufferSize(tokenlist, symboldatabase, errorLogger, settings)),
VFA(valueFlowDebug(tokenlist, errorLogger, settings)), // TODO: add option to print it after each step/iteration
});
}
Expand Down
2 changes: 2 additions & 0 deletions test/cli/other_test.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ def test_progress(tmpdir):
"progress: ValueFlow::valueFlowSwitchVariable(tokenlist, symboldatabase, errorLogger, settings) 1 100%\n"
"progress: ValueFlow::valueFlowForLoop(tokenlist, symboldatabase, errorLogger, settings) 1 0%\n"
"progress: ValueFlow::valueFlowForLoop(tokenlist, symboldatabase, errorLogger, settings) 1 100%\n"
"progress: ValueFlow::valueFlowDynamicBufferSize(tokenlist, symboldatabase, errorLogger, settings) 1 0%\n"
"progress: ValueFlow::valueFlowDynamicBufferSize(tokenlist, symboldatabase, errorLogger, settings) 1 100%\n"
"progress: ValueFlow::valueFlowSubFunction(tokenlist, symboldatabase, errorLogger, settings) 1 0%\n"
"progress: ValueFlow::valueFlowSubFunction(tokenlist, symboldatabase, errorLogger, settings) 1 100%\n"
"progress: ValueFlow::valueFlowFunctionReturn(tokenlist, errorLogger, settings) 1 0%\n"
Expand Down
11 changes: 11 additions & 0 deletions test/testvalueflow.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -7939,6 +7939,17 @@ class TestValueFlow : public TestFixture {
" (void) x;\n"
"}\n";
ASSERT_EQUALS(true, testValueOfX(code, 4U, 0, ValueFlow::Value::ValueType::BUFFER_SIZE));

code = "void f(int *x)\n"
"{\n"
" *x = 1;\n"
"}\n"
"void g(void)\n"
"{\n"
" int *ptr = malloc(1234);\n"
" f(ptr);\n"
"}\n";
ASSERT_EQUALS(true, testValueOfX(code, 3U, 1234, ValueFlow::Value::ValueType::BUFFER_SIZE));
}

void valueFlowSafeFunctionParameterValues() {
Expand Down
Loading

Back | FazBrowse Home | New Git URL