From 4a3988ebbcf4f1aba830d8e3158b7b229d0a48c2 Mon Sep 17 00:00:00 2001 From: Nicolas Roggeman Date: Thu, 10 Oct 2024 08:09:28 +0200 Subject: [PATCH] Fix crashing address review after a blind signing review --- lib_nbgl/src/nbgl_use_case.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib_nbgl/src/nbgl_use_case.c b/lib_nbgl/src/nbgl_use_case.c index c905fe97c..0f3ae0e7e 100644 --- a/lib_nbgl/src/nbgl_use_case.c +++ b/lib_nbgl/src/nbgl_use_case.c @@ -48,9 +48,8 @@ #define QRCODE_REDUCED_ADDR_LEN 128 // macros to ease access to shared contexts -#define keypadContext sharedContext.keypad -#define addressConfirmationContext sharedContext.addressConfirmation -#define blindSigningContext sharedContext.blindSigning +#define keypadContext sharedContext.keypad +#define blindSigningContext sharedContext.blindSigning /********************** * TYPEDEFS @@ -119,13 +118,12 @@ typedef struct BlindSigningContext_s { } BlindSigningContext_t; // this union is intended to save RAM for context storage -// indeed, these three contexts cannot happen simultaneously +// indeed, these 2 contexts cannot happen simultaneously typedef union { #ifdef NBGL_KEYPAD KeypadContext_t keypad; #endif - AddressConfirmationContext_t addressConfirmation; - BlindSigningContext_t blindSigning; + BlindSigningContext_t blindSigning; } SharedContext_t; typedef struct { @@ -216,6 +214,9 @@ static DetailsContext_t detailsContext; // multi-purpose context shared for non-concurrent usages static SharedContext_t sharedContext; +// context for address review +static AddressConfirmationContext_t addressConfirmationContext; + // contexts for generic navigation static GenericContext_t genericContext; static nbgl_content_t @@ -713,7 +714,9 @@ static const nbgl_content_t *genericContextComputeNextPageParams(uint8_t // Handle case where the content to be displayed is in the next content // In such case start at element index 0. - if (nextElementIdx >= genericContext.currentContentElementNb) { + // If currentContentElementNb == 0, means not initialized, so skip + if ((nextElementIdx >= genericContext.currentContentElementNb) + && (genericContext.currentContentElementNb > 0)) { nextContentIdx += 1; nextElementIdx = 0; }