From bcbc6ed57112e1e4ad76fb2db6c9c7b35685b890 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Sat, 31 Jan 2026 05:28:52 +0100 Subject: bignum.c: Replace ruby_xfree by ruby_sized_xfree when applicable --- bignum.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bignum.c b/bignum.c index 345d65064a..c39f74576a 100644 --- a/bignum.c +++ b/bignum.c @@ -3036,12 +3036,13 @@ rb_big_realloc(VALUE big, size_t len) else { if (len <= embed_capa) { ds = RBIGNUM(big)->as.heap.digits; + size_t old_len = RBIGNUM(big)->as.heap.len; FL_SET_RAW(big, BIGNUM_EMBED_FLAG); BIGNUM_SET_LEN(big, len); (void)VALGRIND_MAKE_MEM_UNDEFINED((void*)RBIGNUM(big)->as.ary, embed_capa * sizeof(BDIGIT)); if (ds) { MEMCPY(RBIGNUM(big)->as.ary, ds, BDIGIT, len); - xfree(ds); + SIZED_FREE_N(ds, old_len); } } else { @@ -3049,7 +3050,7 @@ rb_big_realloc(VALUE big, size_t len) RBIGNUM(big)->as.heap.digits = ALLOC_N(BDIGIT, len); } else if (BIGNUM_LEN(big) != len) { - REALLOC_N(RBIGNUM(big)->as.heap.digits, BDIGIT, len); + SIZED_REALLOC_N(RBIGNUM(big)->as.heap.digits, BDIGIT, len, BIGNUM_LEN(big)); } } } -- cgit v1.2.3