Skip to content

Commit b8d3b99

Browse files
committed
Unit test: fix coverity issue
test_wolfSSL_i2d_ASN1_TYPE: don't use str after freeing it.
1 parent db6a2cc commit b8d3b99

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

tests/api.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55178,8 +55178,8 @@ static int test_wolfSSL_i2d_ASN1_TYPE(void)
5517855178
#if defined(OPENSSL_EXTRA)
5517955179
/* Taken from one of sssd's certs othernames */
5518055180
unsigned char str_bin[] = {
55181-
0x04, 0x10, 0xa4, 0x9b, 0xc8, 0xf4, 0x85, 0x8e, 0x89, 0x4d, 0x85, 0x8d,
55182-
0x27, 0xbd, 0x63, 0xaa, 0x93, 0x93
55181+
0x04, 0x10, 0xa4, 0x9b, 0xc8, 0xf4, 0x85, 0x8e, 0x89, 0x4d, 0x85, 0x8d,
55182+
0x27, 0xbd, 0x63, 0xaa, 0x93, 0x93
5518355183
};
5518455184
ASN1_TYPE* asn1type = NULL;
5518555185
unsigned char* der = NULL;
@@ -55190,10 +55190,12 @@ static int test_wolfSSL_i2d_ASN1_TYPE(void)
5519055190
ExpectNotNull(str = ASN1_STRING_type_new(V_ASN1_SEQUENCE));
5519155191
ExpectIntEQ(ASN1_STRING_set(str, str_bin, sizeof(str_bin)), 1);
5519255192
ExpectNotNull(asn1type = ASN1_TYPE_new());
55193-
if (EXPECT_FAIL()) {
55193+
if (asn1type != NULL) {
55194+
ASN1_TYPE_set(asn1type, V_ASN1_SEQUENCE, str);
55195+
}
55196+
else {
5519455197
ASN1_STRING_free(str);
5519555198
}
55196-
ASN1_TYPE_set(asn1type, V_ASN1_SEQUENCE, str);
5519755199
}
5519855200

5519955201
ExpectIntEQ(i2d_ASN1_TYPE(asn1type, NULL), sizeof(str_bin));

0 commit comments

Comments
 (0)