Skip to content

Commit 13689c2

Browse files
committed
Add missing GC_GUARD in fbuffer_append_str
Ref: fff25c9 `StringValuePtr` use `volatile` so the compiler is less likely to re-use the register. But regardless, we should GC_GUARD `str` as we no longer reference it after `GETMEM`.
1 parent a11acc1 commit 13689c2

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

ext/json/ext/fbuffer/fbuffer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ static void fbuffer_append_str(FBuffer *fb, VALUE str)
166166
RSTRING_GETMEM(str, ptr, len);
167167

168168
fbuffer_append(fb, ptr, len);
169+
RB_GC_GUARD(str);
169170
}
170171

171172
static void fbuffer_append_str_repeat(FBuffer *fb, VALUE str, size_t repeat)
@@ -182,6 +183,7 @@ static void fbuffer_append_str_repeat(FBuffer *fb, VALUE str, size_t repeat)
182183
fbuffer_append_reserved(fb, ptr, len);
183184
repeat--;
184185
}
186+
RB_GC_GUARD(str);
185187
}
186188

187189
static inline void fbuffer_append_char(FBuffer *fb, char newchr)

0 commit comments

Comments
 (0)