From df0456b540cd0469353b01e56411e2a17b06498b Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 19 Mar 2026 18:53:18 +0900 Subject: [PATCH 1/2] [ruby/json] Remove unreachable code `rb_exc_raise` never returns. https://github.com/ruby/json/commit/398340fca2 --- ext/json/parser/parser.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/ext/json/parser/parser.c b/ext/json/parser/parser.c index 05cfaa7c685738..3587c4d7d393b2 100644 --- a/ext/json/parser/parser.c +++ b/ext/json/parser/parser.c @@ -909,9 +909,6 @@ NORETURN(static) void raise_duplicate_key_error(JSON_ParserState *state, VALUE d cursor_position(state, &line, &column); rb_str_concat(message, build_parse_error_message("", state, line, column)) ; rb_exc_raise(parse_error_new(message, line, column)); - - raise_parse_error(RSTRING_PTR(message), state); - RB_GC_GUARD(message); } static inline VALUE json_decode_object(JSON_ParserState *state, JSON_ParserConfig *config, size_t count) From d01875d6dd24a3f630b52dc26b3898d74ab9fe77 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 19 Mar 2026 18:55:51 +0900 Subject: [PATCH 2/2] [ruby/json] Reduce an unnecessary intermediate string https://github.com/ruby/json/commit/c5eb1244c7 --- ext/json/parser/parser.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ext/json/parser/parser.c b/ext/json/parser/parser.c index 3587c4d7d393b2..1a8e2aaf485b62 100644 --- a/ext/json/parser/parser.c +++ b/ext/json/parser/parser.c @@ -436,9 +436,8 @@ static VALUE build_parse_error_message(const char *format, JSON_ParserState *sta } } - VALUE msg = rb_sprintf(format, ptr); - VALUE message = rb_enc_sprintf(enc_utf8, "%s at line %ld column %ld", RSTRING_PTR(msg), line, column); - RB_GC_GUARD(msg); + VALUE message = rb_enc_sprintf(enc_utf8, format, ptr); + rb_str_catf(message, " at line %ld column %ld", line, column); return message; }