mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 08:16:15 +02:00
* Override YYMALLOC and YYFREE so that we can call AT[un]protectMemory
on the Bison parse stack. Otherwise, a garbage collect during parsing could lead to a crash.
This commit is contained in:
parent
0ca0a4da9f
commit
2d2e28d02c
1 changed files with 20 additions and 0 deletions
|
@ -43,6 +43,26 @@ static Pos makeCurPos(YYLTYPE * loc, void * data)
|
|||
}
|
||||
|
||||
#define CUR_POS makeCurPos(yylocp, data)
|
||||
|
||||
|
||||
/* Make sure that the parse stack is scanned by the ATerm garbage
|
||||
collector. */
|
||||
static void * mallocAndProtect(size_t size)
|
||||
{
|
||||
void * p = malloc(size);
|
||||
if (p) ATprotectMemory(p, size);
|
||||
return p;
|
||||
}
|
||||
|
||||
static void freeAndUnprotect(void * p)
|
||||
{
|
||||
ATunprotectMemory(p);
|
||||
free(p);
|
||||
}
|
||||
|
||||
#define YYMALLOC mallocAndProtect
|
||||
#define YYFREE freeAndUnprotect
|
||||
|
||||
|
||||
%}
|
||||
|
||||
|
|
Loading…
Reference in a new issue