diff --git a/src/ssl.c b/src/ssl.c index 254b9767a..e6952826a 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -21497,11 +21497,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; diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index 6fd425534..092cca47c 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -13603,10 +13603,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);