mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2024-12-28 16:30:59 +00:00
#define should always use the global pool....
if a #define is within a function, it could use the local memory pool for string allocation (via Malloc in NextToken, line 5785) which can lead to a dangling memory reference when the macro is expanded. void function(void) { #define TEXT "abc" static struct { char text[sizeof(TEXT)]; } template = { TEXT }; }
This commit is contained in:
parent
0aee669746
commit
586229e6eb
@ -2786,8 +2786,12 @@ var
|
||||
ple: stringListPtr; {pointer to the last element in parameterList}
|
||||
pnum: integer; {for counting parameters}
|
||||
tPtr,tk1,tk2: tokenListRecordPtr; {pointer to a token}
|
||||
luseGlobalPool: boolean; {local copy of useGlobalPool}
|
||||
|
||||
begin {DoDefine}
|
||||
|
||||
lUseGlobalPool := useGlobalPool;
|
||||
useGlobalPool := true; {use global memory for defines}
|
||||
expandMacros := false; {block expansions}
|
||||
saveNumber := true; {save characters in numeric tokens}
|
||||
parameterList := nil; {no parameters yet}
|
||||
@ -2999,6 +3003,7 @@ var
|
||||
dispose(np);
|
||||
end; {while}
|
||||
saveNumber := false; {stop saving numeric strings}
|
||||
useGlobalPool := lUseGlobalPool;
|
||||
end; {DoDefine}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user