forked from wolfSSL/wolfssl
src/ssl_load.c: fix double-free in wolfSSL_CTX_SetTmpDH().
This commit is contained in:
@@ -5374,7 +5374,9 @@ int wolfSSL_CTX_SetTmpDH(WOLFSSL_CTX* ctx, const unsigned char* p, int pSz,
|
|||||||
gAlloc = (byte*)XMALLOC(gSz, ctx->heap, DYNAMIC_TYPE_PUBLIC_KEY);
|
gAlloc = (byte*)XMALLOC(gSz, ctx->heap, DYNAMIC_TYPE_PUBLIC_KEY);
|
||||||
if ((pAlloc == NULL) || (gAlloc == NULL)) {
|
if ((pAlloc == NULL) || (gAlloc == NULL)) {
|
||||||
XFREE(pAlloc, ctx->heap, DYNAMIC_TYPE_PUBLIC_KEY);
|
XFREE(pAlloc, ctx->heap, DYNAMIC_TYPE_PUBLIC_KEY);
|
||||||
|
pAlloc = NULL;
|
||||||
XFREE(gAlloc, ctx->heap, DYNAMIC_TYPE_PUBLIC_KEY);
|
XFREE(gAlloc, ctx->heap, DYNAMIC_TYPE_PUBLIC_KEY);
|
||||||
|
gAlloc = NULL;
|
||||||
ret = MEMORY_E;
|
ret = MEMORY_E;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5389,7 +5391,9 @@ int wolfSSL_CTX_SetTmpDH(WOLFSSL_CTX* ctx, const unsigned char* p, int pSz,
|
|||||||
|
|
||||||
if (ret != 1) {
|
if (ret != 1) {
|
||||||
/* Free the allocated buffers if not assigned into SSL context. */
|
/* Free the allocated buffers if not assigned into SSL context. */
|
||||||
|
if (pAlloc)
|
||||||
XFREE(pAlloc, ctx->heap, DYNAMIC_TYPE_PUBLIC_KEY);
|
XFREE(pAlloc, ctx->heap, DYNAMIC_TYPE_PUBLIC_KEY);
|
||||||
|
if (gAlloc)
|
||||||
XFREE(gAlloc, ctx->heap, DYNAMIC_TYPE_PUBLIC_KEY);
|
XFREE(gAlloc, ctx->heap, DYNAMIC_TYPE_PUBLIC_KEY);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
Reference in New Issue
Block a user