Round up the `dstlen` value; fix #3949

The fix was proposed by https://hackerone.com/aerodudrizzt
parent 097bfdca
...@@ -729,7 +729,7 @@ pack_m(mrb_state *mrb, mrb_value src, mrb_value dst, mrb_int didx, long count, u ...@@ -729,7 +729,7 @@ pack_m(mrb_state *mrb, mrb_value src, mrb_value dst, mrb_int didx, long count, u
count -= count % 3; count -= count % 3;
} }
dstlen = srclen / 3 * 4; dstlen = (srclen+2) / 3 * 4;
if (count > 0) { if (count > 0) {
dstlen += (srclen / count) + ((srclen % count) == 0 ? 0 : 1); dstlen += (srclen / count) + ((srclen % count) == 0 ? 0 : 1);
} }
......
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