mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-28 06:53:58 +00:00
Fixed read of potentially junk values in ZScript parser
The following ill-formed ZScript code might crash targets with sizeof(int) != sizeof(void*) like 64-bit Intel class test { void func() { if (true) ( return; ) } }
This commit is contained in:
parent
420602e154
commit
74357ced0c
2 changed files with 21 additions and 0 deletions
|
@ -267,6 +267,7 @@ static void ParseSingleFile(FScanner *pSC, const char *filename, int lump, void
|
|||
|
||||
while (sc.GetToken())
|
||||
{
|
||||
value.Largest = 0;
|
||||
value.SourceLoc = sc.GetMessageLine();
|
||||
switch (sc.TokenType)
|
||||
{
|
||||
|
|
|
@ -7,11 +7,31 @@
|
|||
|
||||
struct ZCCToken
|
||||
{
|
||||
template <typename... Ts>
|
||||
struct TLargest;
|
||||
|
||||
template <typename T>
|
||||
struct TLargest<T>
|
||||
{
|
||||
using Type = T;
|
||||
};
|
||||
|
||||
template <typename T, typename U, typename... Ts>
|
||||
struct TLargest<T, U, Ts...>
|
||||
{
|
||||
using Type = typename TLargest<
|
||||
typename std::conditional<
|
||||
(sizeof(T) > sizeof(U)), T, U
|
||||
>::type, Ts...
|
||||
>::Type;
|
||||
};
|
||||
|
||||
union
|
||||
{
|
||||
int Int;
|
||||
double Float;
|
||||
FString *String;
|
||||
TLargest<decltype(Int), decltype(Float), decltype(String)>::Type Largest;
|
||||
};
|
||||
int SourceLoc;
|
||||
|
||||
|
|
Loading…
Reference in a new issue