Skip to content

Commit 5e79661

Browse files
committed
prevent resource leak if ASN1_INTEGER_to_BN() != null if expected
1 parent f59d50f commit 5e79661

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

tests/api/test_ossl_asn1.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,11 @@ int test_wolfSSL_ASN1_INTEGER_BN(void)
198198
}
199199
#if defined(WOLFSSL_QT) || defined(WOLFSSL_HAPROXY)
200200
ExpectNotNull(bn = ASN1_INTEGER_to_BN(ai, NULL));
201-
BN_free(bn);
202-
bn = NULL;
203201
#else
204-
ExpectNull(ASN1_INTEGER_to_BN(ai, NULL));
202+
ExpectNull(bn = ASN1_INTEGER_to_BN(ai, NULL));
205203
#endif
204+
BN_free(bn);
205+
bn = NULL;
206206

207207
if (ai != NULL) {
208208
ai->data[0] = 0x02; /* tag for ASN_INTEGER */
@@ -213,11 +213,11 @@ int test_wolfSSL_ASN1_INTEGER_BN(void)
213213
#if defined(WOLFSSL_QT) || defined(WOLFSSL_HAPROXY)
214214
/* Interpreted as a number 0x020403. */
215215
ExpectNotNull(bn = ASN1_INTEGER_to_BN(ai, NULL));
216-
BN_free(bn);
217-
bn = NULL;
218216
#else
219-
ExpectNull(ASN1_INTEGER_to_BN(ai, NULL));
217+
ExpectNull(bn = ASN1_INTEGER_to_BN(ai, NULL));
220218
#endif
219+
BN_free(bn);
220+
bn = NULL;
221221

222222
if (ai != NULL) {
223223
ai->data[0] = 0x02; /* tag for ASN_INTEGER */

0 commit comments

Comments
 (0)