DPE: Fix null pointer dereference in debug logging

Changes log_derive_context_output to account for the fact that
new_certificate_actual_size may be NULL if return_certificate is false.

Signed-off-by: Jamie Fox <jamie.fox@arm.com>
Change-Id: Ia1022238b5d17b4559f1c5d4116409e456c69382
diff --git a/partitions/dice_protection_environment/dpe_context_mngr.c b/partitions/dice_protection_environment/dpe_context_mngr.c
index d0121e0..16c5e3b 100644
--- a/partitions/dice_protection_environment/dpe_context_mngr.c
+++ b/partitions/dice_protection_environment/dpe_context_mngr.c
@@ -976,7 +976,7 @@
                               free_component_idx,
                               derived_ctx->linked_cert_ctx,
                               new_certificate_buf,
-                              *new_certificate_actual_size);
+                              new_certificate_actual_size);
 
     return DPE_NO_ERROR;
 
diff --git a/partitions/dice_protection_environment/dpe_log.c b/partitions/dice_protection_environment/dpe_log.c
index bb78f6b..afbd951 100644
--- a/partitions/dice_protection_environment/dpe_log.c
+++ b/partitions/dice_protection_environment/dpe_log.c
@@ -198,7 +198,7 @@
                                int free_component_idx,
                                struct cert_context_t *cert_ctx,
                                uint8_t *new_certificate_buf,
-                               size_t new_certificate_actual_size)
+                               size_t *new_certificate_actual_size)
 {
     log_derive_context_output_handles(*new_parent_context_handle,
                                       *new_context_handle);
@@ -208,9 +208,9 @@
     if (cert_ctx != NULL) {
         log_dpe_cert_ctx_metadata(cert_ctx);
     }
-    if (new_certificate_actual_size > 0) {
+    if (new_certificate_actual_size != NULL && *new_certificate_actual_size > 0) {
         log_intermediate_certificate(new_certificate_buf,
-                                     new_certificate_actual_size);
+                                     *new_certificate_actual_size);
     }
 }
 
diff --git a/partitions/dice_protection_environment/dpe_log.h b/partitions/dice_protection_environment/dpe_log.h
index e21aec7..68b1871 100644
--- a/partitions/dice_protection_environment/dpe_log.h
+++ b/partitions/dice_protection_environment/dpe_log.h
@@ -106,7 +106,7 @@
                                int free_component_idx,
                                struct cert_context_t *cert_ctx,
                                uint8_t *new_certificate_buf,
-                               size_t new_certificate_actual_size);
+                               size_t *new_certificate_actual_size);
 
 #else /* TFM_PARTITION_LOG_LEVEL */