summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2021-06-13 20:13:50 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2021-06-13 20:13:50 +0900
commit1ed01a8d473a4138dbfb10769ce4fb08292b323a (patch)
tree737b7e2fedd4c3d4cc2284e4f181fddb7f95c3c2
parentbf2b06ced78fb0d7d3d120d6db50eab72f0389c5 (diff)
downloadmruby-1ed01a8d473a4138dbfb10769ce4fb08292b323a.tar.gz
mruby-1ed01a8d473a4138dbfb10769ce4fb08292b323a.zip
pack.c: `count` should not be negative for directives `xX@`.
-rw-r--r--mrbgems/mruby-pack/src/pack.c5
1 files changed, 4 insertions, 1 deletions
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);