Merge pull request #6233 from embhorn/gh6209

Support HAVE_SESSION_TICKET without realloc
This commit is contained in:
JacobBarthelmeh
2023-04-05 15:17:58 -06:00
committed by GitHub
2 changed files with 11 additions and 1 deletions

View File

@ -21157,11 +21157,21 @@ static int wolfSSL_DupSessionEx(const WOLFSSL_SESSION* input,
ret = WOLFSSL_FAILURE;
}
else {
#ifdef WOLFSSL_NO_REALLOC
tmp = (byte*)XMALLOC(input->ticketLen,
output->heap, DYNAMIC_TYPE_SESSION_TICK);
XFREE(ticBuff, output->heap, DYNAMIC_TYPE_SESSION_TICK);
ticBuff = NULL;
#else
tmp = (byte*)XREALLOC(ticBuff, input->ticketLen,
output->heap, DYNAMIC_TYPE_SESSION_TICK);
#endif /* WOLFSSL_NO_REALLOC */
if (tmp == NULL) {
WOLFSSL_MSG("Failed to allocate memory for ticket");
#ifndef WOLFSSL_NO_REALLOC
XFREE(ticBuff, output->heap, DYNAMIC_TYPE_SESSION_TICK);
ticBuff = NULL;
#endif /* WOLFSSL_NO_REALLOC */
output->ticket = NULL;
output->ticketLen = 0;
output->ticketLenAlloc = 0;

View File

@ -13607,10 +13607,10 @@ WOLFSSL_TEST_SUBROUTINE int memory_test(void)
#if !defined(USE_FAST_MATH) && !defined(WOLFSSL_NO_MALLOC) && defined(XREALLOC)
/* realloc test */
{
byte *c = NULL;
byte *b = (byte*)XMALLOC(MEM_TEST_SZ, HEAP_HINT,
DYNAMIC_TYPE_TMP_BUFFER);
#ifndef WOLFSSL_NO_REALLOC
byte *c = NULL;
if (b) {
c = (byte*)XREALLOC(b, MEM_TEST_SZ+sizeof(word32), HEAP_HINT,
DYNAMIC_TYPE_TMP_BUFFER);