From 1ed01a8d473a4138dbfb10769ce4fb08292b323a Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Sun, 13 Jun 2021 20:13:50 +0900 Subject: pack.c: `count` should not be negative for directives `xX@`. --- mrbgems/mruby-pack/src/pack.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mrbgems/mruby-pack/src/pack.c b/mrbgems/mruby-pack/src/pack.c index fe3420f36..2724b0688 100644 --- a/mrbgems/mruby-pack/src/pack.c +++ b/mrbgems/mruby-pack/src/pack.c @@ -1251,7 +1251,10 @@ alias: tmpl->idx = e - tptr; continue; } else if (ch == '*') { - count = -1; + if (type == PACK_TYPE_NONE) + count = 0; + else + count = -1; } else if (ch == '_' || ch == '!' || ch == '<' || ch == '>') { if (strchr("sSiIlLqQ", (int)t) == NULL) { mrb_raisef(mrb, E_ARGUMENT_ERROR, "'%c' allowed only after types sSiIlLqQ", ch); -- cgit v1.2.3