Skip to content

Commit

Permalink
wolfcrypt/src/wc_kyber.c: fixes for null derefs (nullPointerRedundant…
Browse files Browse the repository at this point in the history
…Check) in wc_KyberKey_MakeKeyWithRandom() and wc_KyberKey_Decapsulate() added in d350ba6.
  • Loading branch information
douzzer committed Aug 8, 2024
1 parent 763ced6 commit f5e775f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions wolfcrypt/src/wc_kyber.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,9 @@ int wc_KyberKey_MakeKeyWithRandom(KyberKey* key, const unsigned char* rand,
}

/* Free dynamic memory allocated in function. */
XFREE(a, key->heap, DYNAMIC_TYPE_TMP_BUFFER);
if (key != NULL) {
XFREE(a, key->heap, DYNAMIC_TYPE_TMP_BUFFER);
}

return ret;
}
Expand Down Expand Up @@ -890,7 +892,9 @@ int wc_KyberKey_Decapsulate(KyberKey* key, unsigned char* ss,

#ifndef USE_INTEL_SPEEDUP
/* Dispose of dynamic memory allocated in function. */
XFREE(cmp, key->heap, DYNAMIC_TYPE_TMP_BUFFER);
if (key != NULL) {
XFREE(cmp, key->heap, DYNAMIC_TYPE_TMP_BUFFER);
}
#endif

return ret;
Expand Down

0 comments on commit f5e775f

Please sign in to comment.