Skip to content

Commit 78670f5

Browse files
Merge pull request #7453 from douzzer/20240419-wolfSSL_CTX_SetTmpDH-double-free
20240419-wolfSSL_CTX_SetTmpDH-double-free
2 parents 69be7a7 + 39e2405 commit 78670f5

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/ssl_load.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5374,7 +5374,9 @@ int wolfSSL_CTX_SetTmpDH(WOLFSSL_CTX* ctx, const unsigned char* p, int pSz,
53745374
gAlloc = (byte*)XMALLOC(gSz, ctx->heap, DYNAMIC_TYPE_PUBLIC_KEY);
53755375
if ((pAlloc == NULL) || (gAlloc == NULL)) {
53765376
XFREE(pAlloc, ctx->heap, DYNAMIC_TYPE_PUBLIC_KEY);
5377+
pAlloc = NULL;
53775378
XFREE(gAlloc, ctx->heap, DYNAMIC_TYPE_PUBLIC_KEY);
5379+
gAlloc = NULL;
53785380
ret = MEMORY_E;
53795381
}
53805382
}
@@ -5389,8 +5391,10 @@ int wolfSSL_CTX_SetTmpDH(WOLFSSL_CTX* ctx, const unsigned char* p, int pSz,
53895391

53905392
if (ret != 1) {
53915393
/* Free the allocated buffers if not assigned into SSL context. */
5392-
XFREE(pAlloc, ctx->heap, DYNAMIC_TYPE_PUBLIC_KEY);
5393-
XFREE(gAlloc, ctx->heap, DYNAMIC_TYPE_PUBLIC_KEY);
5394+
if (pAlloc)
5395+
XFREE(pAlloc, ctx->heap, DYNAMIC_TYPE_PUBLIC_KEY);
5396+
if (gAlloc)
5397+
XFREE(gAlloc, ctx->heap, DYNAMIC_TYPE_PUBLIC_KEY);
53945398
}
53955399
return ret;
53965400
}

0 commit comments

Comments
 (0)