mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
mruby-bigint: fix missing null terminator in D&C to_s
mpz_to_s_dc_recur fills in exactly num_digits characters but did not add a null terminator. This caused valgrind errors when strlen was called on the resulting string. Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -2755,6 +2755,9 @@ mpz_to_s_dc(mpz_ctx_t *ctx, char *s, mpz_t *x)
|
||||
/* Do the recursive conversion */
|
||||
mpz_to_s_dc_recur(ctx, s, &tmp, num_digits, pow5, num_powers, &scratch);
|
||||
|
||||
/* Null-terminate the string */
|
||||
s[num_digits] = '\0';
|
||||
|
||||
mrb->jmp = prev_jmp;
|
||||
} MRB_CATCH(&c_jmp) {
|
||||
mrb->jmp = prev_jmp;
|
||||
|
||||
Reference in New Issue
Block a user