Skip to content

Commit 0c797b4

Browse files
committed
Trigger write barrier when setting Generator::State configs
Followup: 6382c23
1 parent dd8b3db commit 0c797b4

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

ext/json/ext/generator/generator.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,11 @@ static void vstate_spill(struct generate_json_data *data)
687687
MEMCPY(state, data->state, JSON_Generator_State, 1);
688688
data->state = state;
689689
data->vstate = vstate;
690+
RB_OBJ_WRITTEN(vstate, Qundef, state->indent);
691+
RB_OBJ_WRITTEN(vstate, Qundef, state->space);
692+
RB_OBJ_WRITTEN(vstate, Qundef, state->space_before);
693+
RB_OBJ_WRITTEN(vstate, Qundef, state->object_nl);
694+
RB_OBJ_WRITTEN(vstate, Qundef, state->array_nl);
690695
}
691696

692697
static inline VALUE vstate_get(struct generate_json_data *data)
@@ -1122,7 +1127,7 @@ static VALUE string_config(VALUE config)
11221127
static VALUE cState_indent_set(VALUE self, VALUE indent)
11231128
{
11241129
GET_STATE(self);
1125-
state->indent = string_config(indent);
1130+
RB_OBJ_WRITE(self, &state->indent, string_config(indent));
11261131
return Qnil;
11271132
}
11281133

@@ -1147,7 +1152,7 @@ static VALUE cState_space(VALUE self)
11471152
static VALUE cState_space_set(VALUE self, VALUE space)
11481153
{
11491154
GET_STATE(self);
1150-
state->space = string_config(space);
1155+
RB_OBJ_WRITE(self, &state->space, string_config(space));
11511156
return Qnil;
11521157
}
11531158

@@ -1170,7 +1175,7 @@ static VALUE cState_space_before(VALUE self)
11701175
static VALUE cState_space_before_set(VALUE self, VALUE space_before)
11711176
{
11721177
GET_STATE(self);
1173-
state->space_before = string_config(space_before);
1178+
RB_OBJ_WRITE(self, &state->space_before, string_config(space_before));
11741179
return Qnil;
11751180
}
11761181

@@ -1195,7 +1200,7 @@ static VALUE cState_object_nl(VALUE self)
11951200
static VALUE cState_object_nl_set(VALUE self, VALUE object_nl)
11961201
{
11971202
GET_STATE(self);
1198-
state->object_nl = string_config(object_nl);
1203+
RB_OBJ_WRITE(self, &state->object_nl, string_config(object_nl));
11991204
return Qnil;
12001205
}
12011206

@@ -1218,7 +1223,7 @@ static VALUE cState_array_nl(VALUE self)
12181223
static VALUE cState_array_nl_set(VALUE self, VALUE array_nl)
12191224
{
12201225
GET_STATE(self);
1221-
state->array_nl = string_config(array_nl);
1226+
RB_OBJ_WRITE(self, &state->array_nl, string_config(array_nl));
12221227
return Qnil;
12231228
}
12241229

0 commit comments

Comments
 (0)