mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 02:37:28 +02:00
Merge pull request #2495 from JacobBarthelmeh/staticmemory
check on if free'ing ctx/method back to heap hint
This commit is contained in:
@ -1796,7 +1796,16 @@ void SSL_CtxResourceFree(WOLFSSL_CTX* ctx)
|
||||
wolfEventQueue_Free(&ctx->event_queue);
|
||||
#endif /* HAVE_WOLF_EVENT */
|
||||
|
||||
#ifdef WOLFSSL_STATIC_MEMORY
|
||||
if (ctx->onHeap == 1) {
|
||||
XFREE(ctx->method, ctx->heap, DYNAMIC_TYPE_METHOD);
|
||||
}
|
||||
else {
|
||||
XFREE(ctx->method, NULL, DYNAMIC_TYPE_METHOD);
|
||||
}
|
||||
#else
|
||||
XFREE(ctx->method, ctx->heap, DYNAMIC_TYPE_METHOD);
|
||||
#endif
|
||||
ctx->method = NULL;
|
||||
if (ctx->suites) {
|
||||
XFREE(ctx->suites, ctx->heap, DYNAMIC_TYPE_SUITES);
|
||||
@ -1920,10 +1929,17 @@ void FreeSSL_Ctx(WOLFSSL_CTX* ctx)
|
||||
wc_UnLockMutex(&ctx->countMutex);
|
||||
|
||||
if (doFree) {
|
||||
void* heap = ctx->heap;
|
||||
WOLFSSL_MSG("CTX ref count down to 0, doing full free");
|
||||
SSL_CtxResourceFree(ctx);
|
||||
wc_FreeMutex(&ctx->countMutex);
|
||||
XFREE(ctx, ctx->heap, DYNAMIC_TYPE_CTX);
|
||||
#ifdef WOLFSSL_STATIC_MEMORY
|
||||
if (ctx->onHeap == 0) {
|
||||
heap = NULL;
|
||||
}
|
||||
#endif
|
||||
XFREE(ctx, heap, DYNAMIC_TYPE_CTX);
|
||||
(void)heap; /* not used in some builds */
|
||||
}
|
||||
else {
|
||||
(void)ctx;
|
||||
|
@ -1398,6 +1398,7 @@ int wolfSSL_CTX_load_static_memory(WOLFSSL_CTX** ctx, wolfSSL_method_func method
|
||||
WOLFSSL_MSG("Error creating ctx");
|
||||
return WOLFSSL_FAILURE;
|
||||
}
|
||||
(*ctx)->onHeap = 1; /* free the memory back to heap when done */
|
||||
}
|
||||
|
||||
/* determine what max applies too */
|
||||
|
@ -2617,6 +2617,9 @@ struct WOLFSSL_CTX {
|
||||
#ifdef HAVE_ENCRYPT_THEN_MAC
|
||||
byte disallowEncThenMac:1; /* Don't do Encrypt-Then-MAC */
|
||||
#endif
|
||||
#ifdef WOLFSSL_STATIC_MEMORY
|
||||
byte onHeap:1; /* whether the ctx/method is put on heap hint */
|
||||
#endif
|
||||
#ifdef WOLFSSL_MULTICAST
|
||||
byte haveMcast; /* multicast requested */
|
||||
byte mcastID; /* multicast group ID */
|
||||
|
Reference in New Issue
Block a user