mirror of
https://github.com/github/codeql.git
synced 2026-04-26 17:25:19 +02:00
33 lines
505 B
C
33 lines
505 B
C
|
|
union myUnion1 { // BAD
|
|
int asInt;
|
|
char asChar[4];
|
|
};
|
|
|
|
union myUnion2 { // GOOD
|
|
int asInt;
|
|
char *string;
|
|
};
|
|
|
|
union myUnion3 { // GOOD
|
|
char myChar;
|
|
int arrInt[4];
|
|
};
|
|
|
|
void test1(int *myIntPtr)
|
|
{
|
|
short *myShortPtr = (short *)myIntPtr; // BAD
|
|
long long *myLongPtr = (long long *)myIntPtr; // BAD
|
|
|
|
int myArray[10];
|
|
myIntPtr = (int *)myArray; // GOOD
|
|
myShortPtr = (short *)myArray; // BAD [BUT DOUBLY REPORTED]
|
|
|
|
return 0;
|
|
}
|
|
|
|
union myUnion4 { // GOOD? [FALSE POSITIVE]
|
|
char myChar;
|
|
int myInt;
|
|
};
|