From 072a32601fbb121212f933a1d8c966ce41af954c Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Mon, 13 Jul 2015 10:02:01 +0900 Subject: [PATCH] don't use VLA --- extlib/benz/string.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/extlib/benz/string.c b/extlib/benz/string.c index cc4a0519..f94dfd50 100644 --- a/extlib/benz/string.c +++ b/extlib/benz/string.c @@ -452,19 +452,18 @@ pic_str_make_string(pic_state *pic) { size_t len; char c = ' '; + char *buf; + pic_value ret; pic_get_args(pic, "k|c", &len, &c); - { - size_t i; - char buf[len]; + buf = pic_malloc(pic, len); + memset(buf, c, len); - for (i = 0; i < len; ++i) { - buf[i] = c; - } + ret = pic_obj_value(pic_make_str(pic, buf, len)); - return pic_obj_value(pic_make_str(pic, buf, len)); - } + pic_free(pic, buf); + return ret; } static pic_value