Merge pull request #15448 from microsoft/false_positive_cpp_incorrect_string_type_conversion

cpp/incorrect-string-type-conversion false positive fixes
This commit is contained in:
Mathias Vorreiter Pedersen
2024-01-30 09:37:01 +00:00
committed by GitHub
3 changed files with 45 additions and 1 deletions

View File

@@ -31,4 +31,26 @@ void Test()
fconstWChar((LPCWSTR)lpWchar); // Valid
fWChar(lpWchar); // Valid
}
void NewBufferFalsePositiveTest()
{
wchar_t *lpWchar = NULL;
lpWchar = (LPWSTR)new char[56]; // Possible False Positive
}
typedef unsigned char BYTE;
typedef BYTE* PBYTE;
void NonStringFalsePositiveTest1(PBYTE buffer)
{
wchar_t *lpWchar = NULL;
lpWchar = (LPWSTR)buffer; // Possible False Positive
}
void NonStringFalsePositiveTest2(unsigned char* buffer)
{
wchar_t *lpWchar = NULL;
lpWchar = (LPWSTR)buffer; // Possible False Positive
}