Skip to content

Commit

Permalink
NBGL Nano: Check onActionCallback validity
Browse files Browse the repository at this point in the history
In nbgl_step actionCallback, `onActionCallback` was called without being
checked, leading to crash if the callback is NULL.
This commit adds the relevant checks.
  • Loading branch information
abonnaudet-ledger committed Nov 15, 2024
1 parent fe9d203 commit 263df08
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib_nbgl/src/nbgl_step.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,9 @@ static void actionCallback(nbgl_layout_t *layout, nbgl_buttonEvent_t event)
}
else if ((ctx->textContext.pos == LAST_STEP)
|| (ctx->textContext.pos == NEITHER_FIRST_NOR_LAST_STEP)) {
ctx->textContext.onActionCallback((nbgl_step_t) ctx, event);
if (ctx->textContext.onActionCallback != NULL) {
ctx->textContext.onActionCallback((nbgl_step_t) ctx, event);
}
}
}
else if (event == BUTTON_RIGHT_PRESSED) {
Expand All @@ -319,11 +321,15 @@ static void actionCallback(nbgl_layout_t *layout, nbgl_buttonEvent_t event)
}
else if ((ctx->textContext.pos == FIRST_STEP)
|| (ctx->textContext.pos == NEITHER_FIRST_NOR_LAST_STEP)) {
ctx->textContext.onActionCallback((nbgl_step_t) ctx, event);
if (ctx->textContext.onActionCallback != NULL) {
ctx->textContext.onActionCallback((nbgl_step_t) ctx, event);
}
}
}
else if (event == BUTTON_BOTH_PRESSED) {
ctx->textContext.onActionCallback((nbgl_step_t) ctx, event);
if (ctx->textContext.onActionCallback != NULL) {
ctx->textContext.onActionCallback((nbgl_step_t) ctx, event);
}
}
}

Expand Down

0 comments on commit 263df08

Please sign in to comment.