Skip to content

Commit e887d76

Browse files
committed
fixup! Use wrap strategy
1 parent 33b4bbf commit e887d76

1 file changed

Lines changed: 6 additions & 13 deletions

File tree

ext/openssl/ossl_asn1.c

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,6 @@ asn1str_to_str(const ASN1_STRING *str)
118118
ASN1_STRING_length(str));
119119
}
120120

121-
static VALUE
122-
ossl_bn_new_wrap_i(VALUE arg)
123-
{
124-
return ossl_bn_new((BIGNUM *)arg);
125-
}
126-
127121
/*
128122
* ASN1_INTEGER conversions
129123
*/
@@ -132,22 +126,21 @@ asn1integer_to_num(const ASN1_INTEGER *ai)
132126
{
133127
BIGNUM *bn;
134128
VALUE num;
135-
int st = 0;
136129

137130
if (!ai) {
138131
ossl_raise(rb_eTypeError, "ASN1_INTEGER is NULL!");
139132
}
133+
134+
num = ossl_bn_new(BN_value_one());
135+
bn = GetBNPtr(num);
136+
140137
if (ASN1_STRING_type(ai) == V_ASN1_ENUMERATED)
141-
bn = ASN1_ENUMERATED_to_BN(ai, NULL);
138+
bn = ASN1_ENUMERATED_to_BN(ai, bn);
142139
else
143-
bn = ASN1_INTEGER_to_BN(ai, NULL);
140+
bn = ASN1_INTEGER_to_BN(ai, bn);
144141

145142
if (!bn)
146143
ossl_raise(eOSSLError, NULL);
147-
num = rb_protect(ossl_bn_new_wrap_i, (VALUE)bn, &st);
148-
BN_free(bn);
149-
150-
if (st) rb_jump_tag(st);
151144

152145
return num;
153146
}

0 commit comments

Comments
 (0)