Merge pull request #5507 from haydenroche5/general_names_leak

Fix wolfSSL_GENERAL_NAMES_free memory leak.
This commit is contained in:
David Garske
2022-08-24 21:05:53 -07:00
committed by GitHub
2 changed files with 33 additions and 20 deletions

View File

@ -4315,7 +4315,7 @@ void wolfSSL_GENERAL_NAMES_free(WOLFSSL_GENERAL_NAMES *gens)
return;
}
wolfSSL_sk_free(gens);
wolfSSL_sk_GENERAL_NAME_free(gens);
}
#if defined(OPENSSL_ALL) && !defined(NO_BIO)

View File

@ -41511,6 +41511,8 @@ static int test_wolfSSL_sk_GENERAL_NAME(void)
unsigned char buf[4096];
const unsigned char* bufPt;
int bytes, i;
int j;
XFILE f;
STACK_OF(GENERAL_NAME)* sk;
@ -41521,6 +41523,7 @@ static int test_wolfSSL_sk_GENERAL_NAME(void)
AssertIntGT((bytes = (int)XFREAD(buf, 1, sizeof(buf), f)), 0);
XFCLOSE(f);
for (j = 0; j < 2; ++j) {
bufPt = buf;
AssertNotNull(x509 = d2i_X509(NULL, &bufPt, bytes));
@ -41544,7 +41547,17 @@ static int test_wolfSSL_sk_GENERAL_NAME(void)
}
}
X509_free(x509);
if (j == 0) {
sk_GENERAL_NAME_pop_free(sk, GENERAL_NAME_free);
}
else {
/*
* We had a bug where GENERAL_NAMES_free didn't free all the memory
* it was supposed to. This is a regression test for that bug.
*/
GENERAL_NAMES_free(sk);
}
}
printf(resultFmt, passed);
#endif