fix(lib/psa): fix Null pointer dereference error
Fixing possible Null pointer dereference error, found
by Coverity scan.
Change-Id: If60b7f7e13ecbc3c01e3a9c5005c480260bbabdd
Signed-off-by: David Vincze <david.vincze@arm.com>
diff --git a/lib/psa/measured_boot.c b/lib/psa/measured_boot.c
index 5d3ca8e..693e01f 100644
--- a/lib/psa/measured_boot.c
+++ b/lib/psa/measured_boot.c
@@ -16,18 +16,18 @@
static void print_byte_array(const uint8_t *array, size_t len)
{
- unsigned int i;
+ size_t i;
if (array == NULL || len == 0U) {
(void)printf("\n");
- }
-
- for (i = 0U; i < len; ++i) {
- (void)printf(" %02x", array[i]);
- if ((i & U(0xF)) == U(0xF)) {
- (void)printf("\n");
- if (i < (len - 1U)) {
- INFO("\t\t:");
+ } else {
+ for (i = 0U; i < len; ++i) {
+ (void)printf(" %02x", array[i]);
+ if ((i & U(0xF)) == U(0xF)) {
+ (void)printf("\n");
+ if (i < (len - 1U)) {
+ INFO("\t\t:");
+ }
}
}
}