fix memory leak on error
This commit is contained in:
parent
005309d1eb
commit
61d5661b96
2
parse.c
2
parse.c
@ -371,7 +371,7 @@ IRToks parse(TokList *toks) {
|
||||
for (;;) {
|
||||
if (toks->begin->tok.kind == TokOp && toks->begin->tok.Op == OpEOF)
|
||||
break;
|
||||
TRY_RET(stmt(&s, &global_scope, toks->begin), ir);
|
||||
TRY_RET_ELSE(stmt(&s, &global_scope, toks->begin), ir, term_scope(&global_scope));
|
||||
}
|
||||
term_scope(&global_scope);
|
||||
return ir;
|
||||
|
2
util.h
2
util.h
@ -32,7 +32,9 @@ extern char errbuf[ERRSZ];
|
||||
extern bool err;
|
||||
extern size_t err_ln, err_col;
|
||||
#define TRY(expr) {expr; if (err) return;}
|
||||
#define TRY_ELSE(expr, onerr) {expr; if (err) {onerr; return;}}
|
||||
#define TRY_RET(expr, ret) {expr; if (err) return (ret);}
|
||||
#define TRY_RET_ELSE(expr, ret, onerr) {expr; if (err) {onerr; return (ret);}}
|
||||
void set_err(const char *fmt, ...);
|
||||
|
||||
#define ASSERT_UNREACHED() { fprintf(stderr, "Illegal code position reached in %s:%d\n", __FILE__, __LINE__); exit(1); }
|
||||
|
Loading…
Reference in New Issue
Block a user