Skip to content

Commit bed9067

Browse files
make bn shareable when frozen
1 parent bd647c3 commit bed9067

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

ext/openssl/ossl_bn.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static const rb_data_type_t ossl_bn_type = {
3737
{
3838
0, ossl_bn_free,
3939
},
40-
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
40+
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FROZEN_SHAREABLE,
4141
};
4242

4343
/*
@@ -689,6 +689,7 @@ BIGNUM_3c(mod_exp)
689689
ossl_bn_##func(VALUE self, VALUE bit) \
690690
{ \
691691
BIGNUM *bn; \
692+
rb_check_frozen(self); \
692693
GetBN(self, bn); \
693694
if (BN_##func(bn, NUM2INT(bit)) <= 0) { \
694695
ossl_raise(eBNError, NULL); \
@@ -778,6 +779,7 @@ BIGNUM_SHIFT(rshift)
778779
{ \
779780
BIGNUM *bn; \
780781
int b; \
782+
rb_check_frozen(self); \
781783
b = NUM2INT(bits); \
782784
GetBN(self, bn); \
783785
if (BN_##func(bn, bn, b) <= 0) \
@@ -1187,6 +1189,7 @@ ossl_bn_set_flags(VALUE self, VALUE arg)
11871189
BIGNUM *bn;
11881190
GetBN(self, bn);
11891191

1192+
rb_check_frozen(self);
11901193
BN_set_flags(bn, NUM2INT(arg));
11911194
return Qnil;
11921195
}

0 commit comments

Comments
 (0)