diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2006-02-13T13·09+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2006-02-13T13·09+0000 |
commit | 2d2e28d02c18668856b7d55fad40cac4f875fa3e (patch) | |
tree | 7e6ae3dbb03f4e23da2cc99dbc6f0f7f426caa88 /src/libexpr/parser.y | |
parent | 0ca0a4da9f63c8c036d82c2366f4c794bcd327d2 (diff) |
* 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.
Diffstat (limited to 'src/libexpr/parser.y')
-rw-r--r-- | src/libexpr/parser.y | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y index fe87734f2098..ec07a0191971 100644 --- a/src/libexpr/parser.y +++ b/src/libexpr/parser.y @@ -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 + %} |