Skip to content

Commit dc9aa0f

Browse files
bn ops: only instantiate BN if there were no errors
1 parent af87626 commit dc9aa0f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ext/openssl/ossl_bn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,14 +494,14 @@ BIGNUM_1c(sqr)
494494
BIGNUM *bn1, *bn2 = GetBNPtr(other), *result; \
495495
VALUE obj; \
496496
GetBN(self, bn1); \
497-
obj = NewBN(rb_obj_class(self)); \
498497
if (!(result = BN_new())) { \
499498
ossl_raise(eBNError, NULL); \
500499
} \
501500
if (BN_##func(result, bn1, bn2) <= 0) { \
502501
BN_free(result); \
503502
ossl_raise(eBNError, NULL); \
504503
} \
504+
obj = NewBN(rb_obj_class(self)); \
505505
SetBN(obj, result); \
506506
return obj; \
507507
}

0 commit comments

Comments
 (0)