From f8a32d7d60ff18b7e7851b6b40d23d3f2c64be4d Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Fri, 26 Sep 2014 23:24:26 +0900 Subject: [PATCH] use ptrdiff to extend exception handler stack --- error.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/error.c b/error.c index 568e523b..0f3ac651 100644 --- a/error.c +++ b/error.c @@ -90,7 +90,8 @@ void pic_push_try(pic_state *pic, struct pic_escape *escape) { struct pic_proc *cont, *handler; - size_t xp_len, xp_offset; + size_t xp_len; + ptrdiff_t xp_offset; cont = pic_make_econt(pic, escape); @@ -99,7 +100,7 @@ pic_push_try(pic_state *pic, struct pic_escape *escape) pic_attr_set(pic, pic_obj_value(handler), "@@escape", pic_obj_value(cont)); if (pic->xp >= pic->xpend) { - xp_len = (pic->xpend - pic->xpbase) * 2; + xp_len = (size_t)(pic->xpend - pic->xpbase) * 2; xp_offset = pic->xp - pic->xpbase; pic->xpbase = pic_realloc(pic, pic->xpbase, sizeof(struct pic_proc *) * xp_len); pic->xp = pic->xpbase + xp_offset; @@ -198,12 +199,13 @@ pic_error_with_exception_handler(pic_state *pic) { struct pic_proc *handler, *thunk; pic_value val; - size_t xp_len, xp_offset; + size_t xp_len; + ptrdiff_t xp_offset; pic_get_args(pic, "ll", &handler, &thunk); if (pic->xp >= pic->xpend) { - xp_len = (pic->xpend - pic->xpbase) * 2; + xp_len = (size_t)(pic->xpend - pic->xpbase) * 2; xp_offset = pic->xp - pic->xpbase; pic->xpbase = pic_realloc(pic, pic->xpbase, sizeof(struct pic_proc *) * xp_len); pic->xp = pic->xpbase + xp_offset;