From 11cff8fa7d25f6d114a0784ce478643586a8af5f Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Tue, 22 Oct 2024 14:35:10 +0900 Subject: [PATCH] mruby-bigint (mpz_init_set_str): should skip `+` in the string When the string starts with `+` it should not cause error silently. It might cause serious error afterwards. --- mrbgems/mruby-bigint/core/bigint.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mrbgems/mruby-bigint/core/bigint.c b/mrbgems/mruby-bigint/core/bigint.c index ef092d9e4..8b9aa19d9 100644 --- a/mrbgems/mruby-bigint/core/bigint.c +++ b/mrbgems/mruby-bigint/core/bigint.c @@ -730,6 +730,9 @@ mpz_init_set_str(mrb_state *mrb, mpz_t *x, const char *s, mrb_int len, mrb_int b if (*s == '-') { sn = -1; s++; } + else if (*s == '+') { + sn = 1; s++; + } else sn = 1; for (mrb_int i=0; isn = sn; + x->sn = x->sz == 0 ? 0 : sn; return retval; }