summaryrefslogtreecommitdiff
path: root/ext/json
diff options
context:
space:
mode:
authorJean Boussier <[email protected]>2024-10-31 11:40:05 +0100
committerHiroshi SHIBATA <[email protected]>2024-11-01 13:04:24 +0900
commitb85a7a44fa05da4078c8b0e20445947d8551788d (patch)
tree760fc7b92767b89db7ce11b72a9ff405c8d85c40 /ext/json
parentef5565f5d17c5c8a0557637cf40e5124b0eebb5c (diff)
[ruby/json] Trigger write barrier when setting Generator::State configs
Followup: https://github.com/ruby/json/commit/6382c231b0b8 https://github.com/ruby/json/commit/0c797b4a11
Diffstat (limited to 'ext/json')
-rw-r--r--ext/json/generator/generator.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/ext/json/generator/generator.c b/ext/json/generator/generator.c
index 8f0ef207de..362eff7f73 100644
--- a/ext/json/generator/generator.c
+++ b/ext/json/generator/generator.c
@@ -687,6 +687,11 @@ static void vstate_spill(struct generate_json_data *data)
MEMCPY(state, data->state, JSON_Generator_State, 1);
data->state = state;
data->vstate = vstate;
+ RB_OBJ_WRITTEN(vstate, Qundef, state->indent);
+ RB_OBJ_WRITTEN(vstate, Qundef, state->space);
+ RB_OBJ_WRITTEN(vstate, Qundef, state->space_before);
+ RB_OBJ_WRITTEN(vstate, Qundef, state->object_nl);
+ RB_OBJ_WRITTEN(vstate, Qundef, state->array_nl);
}
static inline VALUE vstate_get(struct generate_json_data *data)
@@ -1122,7 +1127,7 @@ static VALUE string_config(VALUE config)
static VALUE cState_indent_set(VALUE self, VALUE indent)
{
GET_STATE(self);
- state->indent = string_config(indent);
+ RB_OBJ_WRITE(self, &state->indent, string_config(indent));
return Qnil;
}
@@ -1147,7 +1152,7 @@ static VALUE cState_space(VALUE self)
static VALUE cState_space_set(VALUE self, VALUE space)
{
GET_STATE(self);
- state->space = string_config(space);
+ RB_OBJ_WRITE(self, &state->space, string_config(space));
return Qnil;
}
@@ -1170,7 +1175,7 @@ static VALUE cState_space_before(VALUE self)
static VALUE cState_space_before_set(VALUE self, VALUE space_before)
{
GET_STATE(self);
- state->space_before = string_config(space_before);
+ RB_OBJ_WRITE(self, &state->space_before, string_config(space_before));
return Qnil;
}
@@ -1195,7 +1200,7 @@ static VALUE cState_object_nl(VALUE self)
static VALUE cState_object_nl_set(VALUE self, VALUE object_nl)
{
GET_STATE(self);
- state->object_nl = string_config(object_nl);
+ RB_OBJ_WRITE(self, &state->object_nl, string_config(object_nl));
return Qnil;
}
@@ -1218,7 +1223,7 @@ static VALUE cState_array_nl(VALUE self)
static VALUE cState_array_nl_set(VALUE self, VALUE array_nl)
{
GET_STATE(self);
- state->array_nl = string_config(array_nl);
+ RB_OBJ_WRITE(self, &state->array_nl, string_config(array_nl));
return Qnil;
}