diff options
author | Jean Boussier <[email protected]> | 2025-04-27 11:10:00 +0200 |
---|---|---|
committer | Jean Boussier <[email protected]> | 2025-04-30 08:12:41 +0200 |
commit | 5566a7f7402197002a8d12420230f32d5fff727b () | |
tree | 7f7910933769906d02c076bd0200af8cc8dd5897 /ext/json/generator | |
parent | 1103611600fd64569b450619bca68f7ef00dddfb (diff) |
[ruby/json] Handle non-string keys returning immediate values via `to_s`
We can't directly call `RBASIC_CLASS` as the return value of `to_s` may be an immediate. https://.com/ruby/json/commit/12dc394d11
-rw-r--r-- | ext/json/generator/generator.c | 17 |
1 files changed, 16 insertions, 1 deletions
@@ -789,6 +789,21 @@ struct hash_foreach_arg { int iter; }; static int json_object_i(VALUE key, VALUE val, VALUE _arg) { @@ -817,7 +832,7 @@ json_object_i(VALUE key, VALUE val, VALUE _arg) if (RB_LIKELY(RBASIC_CLASS(key) == rb_cString)) { key_to_s = key; } else { - key_to_s = rb_funcall(key, i_to_s, 0); } break; case T_SYMBOL: |