Skip to content

Commit 6c4fae9

Browse files
committed
don't allow non-blank character before cppcheck-suppress
1 parent 51fe5da commit 6c4fae9

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

lib/suppressions.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,15 @@ std::vector<Suppressions::Suppression> Suppressions::parseMultiSuppressComment(s
118118
if (comment.size() < 2)
119119
return suppressions;
120120

121-
const std::size_t suppress_position = comment.find("cppcheck-suppress");
121+
const std::size_t first_non_blank_position = comment.find_first_not_of(" \t\n", 2);
122+
const std::size_t suppress_position = comment.find("cppcheck-suppress", 2);
122123
if (suppress_position == std::string::npos)
123124
return suppressions;
125+
if (suppress_position != first_non_blank_position) {
126+
if (errorMessage && errorMessage->empty())
127+
*errorMessage = "Bad multi suppression '" + comment + "'. there shouldn't have non-blank character before cppcheck-suppress";
128+
return suppressions;
129+
}
124130

125131
const std::size_t start_position = comment.find("[", suppress_position);
126132
const std::size_t end_position = comment.find("]", suppress_position);

0 commit comments

Comments
 (0)