From a926c54be3d748117236e5e5fa4f512648385459 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Thu, 24 Oct 2013 03:38:29 +0900 Subject: [PATCH] warn invalid application --- include/picrin/proc.h | 2 ++ src/vm.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/include/picrin/proc.h b/include/picrin/proc.h index 7d6dcd92..c29b6c36 100644 --- a/include/picrin/proc.h +++ b/include/picrin/proc.h @@ -19,6 +19,8 @@ struct pic_proc { pic_value aux; }; +#define pic_proc_p(o) (pic_type(o) == PIC_TT_PROC) + #define pic_proc_ptr(o) ((struct pic_proc *)(o).u.data) #define pic_proc_cfunc_p(o) (pic_proc_ptr(o)->cfunc_p) diff --git a/src/vm.c b/src/vm.c index 1dc31bf7..1e2bb2b3 100644 --- a/src/vm.c +++ b/src/vm.c @@ -224,6 +224,10 @@ pic_run(pic_state *pic, struct pic_proc *proc, pic_value args) struct pic_proc *proc; c = pic->sp[-pc->u.i]; + if (! pic_proc_p(c)) { + pic->errmsg = "invalid application"; + goto L_RAISE; + } proc = pic_proc_ptr(c); ci = PUSHCI();