unpack.c: check if srcidx is shorter than srclen for safety.

This commit is contained in:
Yukihiro "Matz" Matsumoto
2022-03-04 14:19:10 +09:00
parent bc9476e7ca
commit 278f46f971
+1 -1
View File
@@ -1525,7 +1525,7 @@ pack_unpack(mrb_state *mrb, mrb_value str, int single)
break;
}
while (count != 0) {
while (count != 0 && srcidx < srclen) {
if (srclen - srcidx < size) {
while (count-- > 0) {
mrb_ary_push(mrb, result, mrb_nil_value());