coverity: fix error, and cleanup.

This commit is contained in:
jordan
2024-10-21 14:59:32 -05:00
parent 104c805b82
commit 35def11781
2 changed files with 21 additions and 10 deletions

View File

@@ -13594,14 +13594,21 @@ static int ProcessCSR_ex(WOLFSSL* ssl, byte* input, word32* inOutIdx,
DYNAMIC_TYPE_OCSP_REQUEST); DYNAMIC_TYPE_OCSP_REQUEST);
if (status == NULL || single == NULL || response == NULL) { if (status == NULL || single == NULL || response == NULL) {
if (status != NULL) {
XFREE(status, ssl->heap, DYNAMIC_TYPE_OCSP_STATUS); XFREE(status, ssl->heap, DYNAMIC_TYPE_OCSP_STATUS);
}
if (single != NULL) {
XFREE(single, ssl->heap, DYNAMIC_TYPE_OCSP_ENTRY); XFREE(single, ssl->heap, DYNAMIC_TYPE_OCSP_ENTRY);
}
if (response != NULL) {
XFREE(response, ssl->heap, DYNAMIC_TYPE_OCSP_REQUEST); XFREE(response, ssl->heap, DYNAMIC_TYPE_OCSP_REQUEST);
}
return MEMORY_ERROR; return MEMORY_ERROR;
} }
#endif #endif
/* InitOcspResponse sets single and status to response struct. */
InitOcspResponse(response, single, status, input +*inOutIdx, status_length, ssl->heap); InitOcspResponse(response, single, status, input +*inOutIdx, status_length, ssl->heap);
if (OcspResponseDecode(response, SSL_CM(ssl), ssl->heap, 0) != 0) if (OcspResponseDecode(response, SSL_CM(ssl), ssl->heap, 0) != 0)
@@ -13622,6 +13629,8 @@ static int ProcessCSR_ex(WOLFSSL* ssl, byte* input, word32* inOutIdx,
*inOutIdx += status_length; *inOutIdx += status_length;
/* FreeOcspResponse frees status and single only if
* single->isDynamic is set. */
FreeOcspResponse(response); FreeOcspResponse(response);
#ifdef WOLFSSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK

View File

@@ -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); ALLOC_SP_INT(d, m->used + 1, err, NULL);
if (err == MP_OKAY) { 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 */ /* 1. x = m, y = a, b = 1, c = 0 */
if (a != y) { if (a != y) {
_sp_copy(a, y); _sp_copy(a, y);