From c1d6d55f5af4b06372c6a016907a351e1ed7414f Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 2 Oct 2024 22:03:32 +0900 Subject: [PATCH] Assert in only one place just after adding an argument --- version.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/version.c b/version.c index 3bf3ff1db4..416688644a 100644 --- a/version.c +++ b/version.c @@ -171,8 +171,9 @@ define_ruby_description(const char *const jit_opt) int n = ruby_description_opt_point; memcpy(desc, ruby_description, n); -# define append(s) (n += (int)strlcpy(desc + n, s, sizeof(desc) - n), assert(n < sizeof(desc))) +# define append(s) (n += (int)strlcpy(desc + n, s, sizeof(desc) - n)) if (*jit_opt) append(jit_opt); + RUBY_ASSERT(n <= ruby_description_opt_point + (int)rb_strlen_lit(YJIT_DESCRIPTION)); if (ruby_mn_threads_enabled) append(" +MN"); if (rb_ruby_prism_p()) append(" +PRISM"); append(ruby_description + ruby_description_opt_point);