Skip to content

Commit b7648bc

Browse files
committed
Adding test cases.
1 parent 562221f commit b7648bc

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

cpp/ql/test/query-tests/Security/CWE/CWE-704/WcharCharConversion.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,26 @@ void Test()
3131

3232
fconstWChar((LPCWSTR)lpWchar); // Valid
3333
fWChar(lpWchar); // Valid
34+
}
35+
36+
void NewBufferFalsePositiveTest()
37+
{
38+
wchar_t *lpWchar = NULL;
39+
40+
lpWchar = (LPWSTR)new char[56]; // Possible False Positive
41+
}
42+
43+
typedef unsigned char BYTE;
44+
typedef BYTE* PBYTE;
45+
46+
void NonStringFalsePositiveTest1(PBYTE buffer)
47+
{
48+
wchar_t *lpWchar = NULL;
49+
lpWchar = (LPWSTR)buffer; // Possible False Positive
50+
}
51+
52+
void NonStringFalsePositiveTest2(unsigned char* buffer)
53+
{
54+
wchar_t *lpWchar = NULL;
55+
lpWchar = (LPWSTR)buffer; // Possible False Positive
3456
}

0 commit comments

Comments
 (0)