Skip to content

Commit edcaa40

Browse files
authored
RUBY-3557 Mark SecureRandom as Global (#341)
SecureRandom needs to be marked global so that it does not possibly get moved during GC compaction.
1 parent e1f5d8f commit edcaa40

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

ext/bson/util.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ VALUE pvt_load_secure_random(VALUE _arg) {
170170
pvt_SecureRandom = rb_const_get(rb_cObject, rb_intern("SecureRandom"));
171171
pvt_has_random_number = rb_respond_to(pvt_SecureRandom, rb_intern("random_number"));
172172

173+
// mark SecureRandom so it does not get moved
174+
rb_global_variable(&pvt_SecureRandom);
175+
173176
return Qnil;
174177
}
175178

0 commit comments

Comments
 (0)