pack.c: check overflow before calling pack_x.

This commit is contained in:
Yukihiro "Matz" Matsumoto
2021-06-06 08:01:58 +09:00
parent d518294f20
commit e112c46281
+1 -1
View File
@@ -1191,8 +1191,8 @@ mrb_pack_pack(mrb_state *mrb, mrb_value ary)
if (dir == PACK_DIR_INVALID)
continue;
else if (dir == PACK_DIR_NUL) {
if (count > 0 && ridx > INT_MAX - count) goto overflow;
ridx += pack_x(mrb, mrb_nil_value(), result, ridx, count, flags);
if (ridx < 0) goto overflow;
continue;
}