dump.c: add type cast to retrieve bigint length from the pool

If bigint representation is too long, the retrieved length (without type
cast) can be considered as negative. To avoid the issue, we have to add
type cast before assignments.
This commit is contained in:
Yukihiro "Matz" Matsumoto
2025-07-24 12:30:04 +09:00
parent 6f5dd98951
commit 0e91696397
+2 -2
View File
@@ -165,7 +165,7 @@ get_pool_block_size(mrb_state *mrb, const mrb_irep *irep)
case IREP_TT_BIGINT:
{
mrb_int len = irep->pool[pool_no].u.str[0];
mrb_int len = (uint8_t)irep->pool[pool_no].u.str[0];
mrb_assert_int_fit(mrb_int, len, size_t, SIZE_MAX);
size += (size_t)len+2;
}
@@ -242,7 +242,7 @@ write_pool_block(mrb_state *mrb, const mrb_irep *irep, uint8_t *buf)
case IREP_TT_BIGINT:
cur += uint8_to_bin(IREP_TT_BIGINT, cur); /* data type */
len = irep->pool[pool_no].u.str[0];
len = (uint8_t)irep->pool[pool_no].u.str[0];
memcpy(cur, irep->pool[pool_no].u.str, (size_t)len+2);
cur += len+2;
break;