Fixed #806 (cppcheck crashes scanning openssl)
This commit is contained in:
parent
dbfba8c2a6
commit
67f53661a9
|
@ -4291,8 +4291,11 @@ std::string Tokenizer::simplifyString(const std::string &source)
|
|||
// We will replace all other character as 'a'
|
||||
// If that causes problems in the future, this can
|
||||
// be improved. But for now, this should be OK.
|
||||
int n = 1;
|
||||
while (n < 2 && std::isxdigit(str[i+1+n]))
|
||||
++n;
|
||||
--i;
|
||||
str.replace(i, 4, "a");
|
||||
str.replace(i, 2 + n, "a");
|
||||
}
|
||||
}
|
||||
else if (MathLib::isOctalDigit(str[i]))
|
||||
|
|
|
@ -158,6 +158,8 @@ private:
|
|||
TEST_CASE(removeExceptionSpecification);
|
||||
|
||||
TEST_CASE(gt); // use "<" comparisons instead of ">"
|
||||
|
||||
TEST_CASE(simplifyString);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2542,6 +2544,16 @@ private:
|
|||
ASSERT_EQUALS("; i < 10 ;", tokenizeAndStringify(";10>i;"));
|
||||
}
|
||||
|
||||
|
||||
void simplifyString()
|
||||
{
|
||||
Tokenizer *tokenizer = 0;
|
||||
ASSERT_EQUALS("\"abc\"", tokenizer->simplifyString("\"abc\""));
|
||||
ASSERT_EQUALS("\"a\"", tokenizer->simplifyString("\"\\x3\""));
|
||||
ASSERT_EQUALS("\"a\"", tokenizer->simplifyString("\"\\x33\""));
|
||||
ASSERT_EQUALS("\"a3\"", tokenizer->simplifyString("\"\\x333\""));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestTokenizer)
|
||||
|
|
Loading…
Reference in New Issue