pack.c: check overflow before calling `pack_x`.

parent d518294f
...@@ -1191,8 +1191,8 @@ mrb_pack_pack(mrb_state *mrb, mrb_value ary) ...@@ -1191,8 +1191,8 @@ mrb_pack_pack(mrb_state *mrb, mrb_value ary)
if (dir == PACK_DIR_INVALID) if (dir == PACK_DIR_INVALID)
continue; continue;
else if (dir == PACK_DIR_NUL) { 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); ridx += pack_x(mrb, mrb_nil_value(), result, ridx, count, flags);
if (ridx < 0) goto overflow;
continue; continue;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment