Skip to content

Commit

Permalink
fix memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
miyazakh committed Jul 24, 2024
1 parent 671a503 commit 3e5553d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -3135,7 +3135,7 @@ static void TLSX_CSR_Free(CertificateStatusRequest* csr, void* heap)
#ifdef WOLFSSL_TLS13
for(i = 0; i < (1 + MAX_CHAIN_DEPTH);i++) {
if (csr->responses[i].buffer != NULL) {
XFREE(csr->responses[i].buffer, csr->ssl->heap,
XFREE(csr->responses[i].buffer, heap,
DYNAMIC_TYPE_TMP_BUFFER);
}
}
Expand Down Expand Up @@ -3461,6 +3461,12 @@ static int TLSX_CSR_Parse(WOLFSSL* ssl, const byte* input, word16 length,

request = &csr->request.ocsp[0];
ret = CreateOcspResponse(ssl, &request, &csr->responses[0]);
if (request != &csr->request.ocsp[0] &&
ssl->buffers.weOwnCert) {
/* request will be allocated in CreateOcspResponse() */
FreeOcspRequest(request);
XFREE(request, ssl->heap, DYNAMIC_TYPE_OCSP_REQUEST);
}
if (ret != 0)
return ret;
if (csr->responses[0].buffer)
Expand All @@ -3486,7 +3492,7 @@ static int TLSX_CSR_Parse(WOLFSSL* ssl, const byte* input, word16 length,

if (pos > chain->length)
break;

request = &csr->request.ocsp[i + 1];
ret = CreateOcspRequest(ssl, request, cert, der.buffer,
der.length);
if (ret == 0 && request == ssl->ctx->certOcspRequest) {
Expand All @@ -3503,6 +3509,7 @@ static int TLSX_CSR_Parse(WOLFSSL* ssl, const byte* input, word16 length,
ret = 0;
}
i++;
csr->requests++;
}
}
}
Expand Down

0 comments on commit 3e5553d

Please sign in to comment.