mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 18:57:27 +02:00
Merge pull request #5507 from haydenroche5/general_names_leak
Fix wolfSSL_GENERAL_NAMES_free memory leak.
This commit is contained in:
@ -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)
|
||||
|
13
tests/api.c
13
tests/api.c
@ -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
|
||||
|
Reference in New Issue
Block a user