From 32fa44db917e21c3c4dd07b1b9bf2825e2ab147e Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Fri, 26 Sep 2014 14:23:47 +0900 Subject: [PATCH] integer->char: assure given integer range --- char.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/char.c b/char.c index a460fb2b..98eed6f7 100644 --- a/char.c +++ b/char.c @@ -31,7 +31,11 @@ pic_char_integer_to_char(pic_state *pic) pic_get_args(pic, "i", &i); - return pic_char_value(i); + if (i < 0 || i > 127) { + pic_errorf(pic, "integer->char: integer out of char range: %d", i); + } + + return pic_char_value((char)i); } #define DEFINE_CHAR_CMP(op, name) \