aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gencode.c10
-rw-r--r--gencode.h2
-rw-r--r--grammar.y2
3 files changed, 11 insertions, 3 deletions
diff --git a/gencode.c b/gencode.c
index 5af22d5e..bacc713c 100644
--- a/gencode.c
+++ b/gencode.c
@@ -927,12 +927,19 @@ merge(struct block *b0, struct block *b1)
*p = b1;
}
-void
+int
finish_parse(compiler_state_t *cstate, struct block *p)
{
struct block *ppi_dlt_check;
/*
+ * Catch errors reported by us and routines below us, and return -1
+ * on an error.
+ */
+ if (setjmp(cstate->top_ctx))
+ return (-1);
+
+ /*
* Insert before the statements of the first (root) block any
* statements needed to load the lengths of any variable-length
* headers into registers.
@@ -974,6 +981,7 @@ finish_parse(compiler_state_t *cstate, struct block *p)
p->sense = !p->sense;
backpatch(p, gen_retblk(cstate, 0));
cstate->ic.root = p->head;
+ return (0);
}
void
diff --git a/gencode.h b/gencode.h
index 9920de7d..cc21e043 100644
--- a/gencode.h
+++ b/gencode.h
@@ -370,7 +370,7 @@ int bpf_optimize(struct icode *, char *);
void bpf_set_error(compiler_state_t *, const char *, ...)
PCAP_PRINTFLIKE(2, 3);
-void finish_parse(compiler_state_t *, struct block *);
+int finish_parse(compiler_state_t *, struct block *);
char *sdup(compiler_state_t *, const char *);
struct bpf_insn *icode_to_fcode(struct icode *, struct block *, u_int *,
diff --git a/grammar.y b/grammar.y
index 2d938864..0db5a544 100644
--- a/grammar.y
+++ b/grammar.y
@@ -382,7 +382,7 @@ DIAG_OFF_BISON_BYACC
%%
prog: null expr
{
- finish_parse(cstate, $2.b);
+ CHECK_INT_VAL(finish_parse(cstate, $2.b));
}
| null
;