Skip to content

Commit

Permalink
coverity: fix error, and cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
philljj committed Oct 21, 2024
1 parent 104c805 commit 35def11
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
27 changes: 18 additions & 9 deletions src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -13587,21 +13587,28 @@ static int ProcessCSR_ex(WOLFSSL* ssl, byte* input, word32* inOutIdx,

#ifdef WOLFSSL_SMALL_STACK
status = (CertStatus*)XMALLOC(sizeof(CertStatus), ssl->heap,
DYNAMIC_TYPE_OCSP_STATUS);
DYNAMIC_TYPE_OCSP_STATUS);
single = (OcspEntry*)XMALLOC(sizeof(OcspEntry), ssl->heap,
DYNAMIC_TYPE_OCSP_ENTRY);
DYNAMIC_TYPE_OCSP_ENTRY);
response = (OcspResponse*)XMALLOC(sizeof(OcspResponse), ssl->heap,
DYNAMIC_TYPE_OCSP_REQUEST);
DYNAMIC_TYPE_OCSP_REQUEST);

if (status == NULL || single == NULL || response == NULL) {
XFREE(status, ssl->heap, DYNAMIC_TYPE_OCSP_STATUS);
XFREE(single, ssl->heap, DYNAMIC_TYPE_OCSP_ENTRY);
XFREE(response, ssl->heap, DYNAMIC_TYPE_OCSP_REQUEST);
if (status != NULL) {
XFREE(status, ssl->heap, DYNAMIC_TYPE_OCSP_STATUS);
}
if (single != NULL) {
XFREE(single, ssl->heap, DYNAMIC_TYPE_OCSP_ENTRY);
}
if (response != NULL) {
XFREE(response, ssl->heap, DYNAMIC_TYPE_OCSP_REQUEST);
}

return MEMORY_ERROR;
}
#endif

/* InitOcspResponse sets single and status to response struct. */
InitOcspResponse(response, single, status, input +*inOutIdx, status_length, ssl->heap);

if (OcspResponseDecode(response, SSL_CM(ssl), ssl->heap, 0) != 0)
Expand All @@ -13622,12 +13629,14 @@ static int ProcessCSR_ex(WOLFSSL* ssl, byte* input, word32* inOutIdx,

*inOutIdx += status_length;

/* FreeOcspResponse frees status and single only if
* single->isDynamic is set. */
FreeOcspResponse(response);

#ifdef WOLFSSL_SMALL_STACK
XFREE(status, ssl->heap, DYNAMIC_TYPE_OCSP_STATUS);
XFREE(single, ssl->heap, DYNAMIC_TYPE_OCSP_ENTRY);
XFREE(response, ssl->heap, DYNAMIC_TYPE_OCSP_REQUEST);
XFREE(status, ssl->heap, DYNAMIC_TYPE_OCSP_STATUS);
XFREE(single, ssl->heap, DYNAMIC_TYPE_OCSP_ENTRY);
XFREE(response, ssl->heap, DYNAMIC_TYPE_OCSP_REQUEST);
#endif

WOLFSSL_LEAVE("ProcessCSR", ret);
Expand Down
4 changes: 3 additions & 1 deletion wolfcrypt/src/sp_int.c
Original file line number Diff line number Diff line change
Expand Up @@ -12429,8 +12429,10 @@ static int _sp_invmod_div(const sp_int* a, const sp_int* m, sp_int* x,

ALLOC_SP_INT(d, m->used + 1, err, NULL);
if (err == MP_OKAY) {
sp_init_size(d, m->used + 1);
err = sp_init_size(d, m->used + 1);
}

if (err == MP_OKAY) {
/* 1. x = m, y = a, b = 1, c = 0 */
if (a != y) {
_sp_copy(a, y);
Expand Down

0 comments on commit 35def11

Please sign in to comment.