From c5cc1c3a92b1a80bb93e484a9c954066afd3a123 Mon Sep 17 00:00:00 2001 From: David Horstmann Date: Wed, 15 Nov 2023 18:11:26 +0000 Subject: [PATCH] Remove redundant NULL check A NULL buffer with a non-zero length is an internal error, so just check the length. Signed-off-by: David Horstmann --- library/psa_crypto.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 43495e247e..167ce2d173 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -8504,9 +8504,7 @@ psa_status_t psa_crypto_input_copy_alloc(const uint8_t *input, size_t input_len, input_copy->buffer = NULL; input_copy->len = 0; - /* Treat NULL and zero-length input the same. - * This is simpler than potentially calling calloc(0). */ - if (input == NULL || input_len == 0) { + if (input_len == 0) { return PSA_SUCCESS; } @@ -8549,9 +8547,7 @@ psa_status_t psa_crypto_output_copy_alloc(uint8_t *output, size_t output_len, output_copy->buffer = NULL; output_copy->len = 0; - /* Treat NULL and zero-length input the same. - * This is simpler than potentially calling calloc(0). */ - if (output == NULL || output_len == 0) { + if (output_len == 0) { return PSA_SUCCESS; } output_copy->buffer = mbedtls_calloc(output_len, 1);