Enable YYSTACK_USE_ALLOCA.

It used heap allocated memory for the parser stack, but there's
possibility of parser termination by exceptions. In that case, the
parser stack memory is leaked.

We were afraid of stack consumption, but parser stack size is only 4KB,
so we don't have to worry about it (at least for the parser).
This commit is contained in:
Yukihiro "Matz" Matsumoto
2019-05-16 11:46:37 +09:00
parent 304b52fabe
commit 9b604abc83
+1 -7
View File
@@ -10,13 +10,7 @@
# define YYDEBUG 1
#endif
#define YYERROR_VERBOSE 1
/*
* Force yacc to use our memory management. This is a little evil because
* the macros assume that "parser_state *p" is in scope
*/
#define YYMALLOC(n) mrb_malloc(p->mrb, (n))
#define YYFREE(o) mrb_free(p->mrb, (o))
#define YYSTACK_USE_ALLOCA 0
#define YYSTACK_USE_ALLOCA 1
#include <ctype.h>
#include <errno.h>