Skip to content

Commit 6b29143

Browse files
committed
fix issue for invalidScanfArgType_int output not being generic
1 parent af98d3b commit 6b29143

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

cli/cppcheckexecutor.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,15 @@ namespace {
141141
result = std::regex_replace(result, nullPtrPattern, "Null pointer dereference");
142142
}
143143

144+
// Invalid scanf argument type patterns
145+
if (ruleId == "invalidScanfArgType_int" || ruleId.find("invalidScanfArgType") == 0)
146+
{
147+
// Replace "%format in format string (no. N) requires 'type *' but the argument type is 'type *'."
148+
// with "Format specifier in format string requires different argument type."
149+
std::regex scanfPattern(R"(%\w+ in format string \(no\. \d+\) requires '[^']*' but the argument type is '[^']*'\.)");
150+
result = std::regex_replace(result, scanfPattern, "Format specifier in format string requires different argument type.");
151+
}
152+
144153
// Variable name patterns - replace specific variable names with generic terms
145154
// But be careful not to replace legitimate words like "pointer" in "C-style pointer casting"
146155

0 commit comments

Comments
 (0)