Do so, and return -1 on an error and 0 otherwise. Check the return
value when it's called.
*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
p->sense = !p->sense;
backpatch(p, gen_retblk(cstate, 0));
cstate->ic.root = p->head;
+ return (0);
}
void
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 *,
%%
prog: null expr
{
- finish_parse(cstate, $2.b);
+ CHECK_INT_VAL(finish_parse(cstate, $2.b));
}
| null
;