From ee5920a7d5c3b26dfcf492254fe1323d3da2badf Mon Sep 17 00:00:00 2001 From: Ryan Everett Date: Fri, 9 Feb 2024 15:09:28 +0000 Subject: [PATCH] Fix error path in `psa_key_derivation_output_bytes` Co-authored-by: David Horstmann Signed-off-by: Ryan Everett --- library/psa_crypto.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 5ad9f23df8..00eef4c97e 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -5881,7 +5881,9 @@ exit: psa_algorithm_t alg = operation->alg; psa_key_derivation_abort(operation); operation->alg = alg; - memset(output, '!', output_length); + if (output != NULL) { + memset(output, '!', output_length); + } } LOCAL_OUTPUT_FREE(output_external, output);