Hi Serhei,

On Thu, Apr 9, 2026 at 7:15 PM Serhei Makarov <[email protected]> wrote:
>
> I believe the way things were setup on x86 meant this never triggered
> (since n_regs == n_regs_mapping, the for loop would stop at the
> correct moment), but the logic here looks clearly incorrect for the
> general case. Fix.
>
> * libebl/eblinitreg_sample.c (ebl_set_initial_registers_sample):
>   Be sure to break when i == n_regs_mapping, which is out of range.
>
> Signed-off-by: Serhei Makarov <[email protected]>
> ---
>  libebl/eblinitreg_sample.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libebl/eblinitreg_sample.c b/libebl/eblinitreg_sample.c
> index ca756c90..daf57d3c 100644
> --- a/libebl/eblinitreg_sample.c
> +++ b/libebl/eblinitreg_sample.c
> @@ -71,7 +71,7 @@ ebl_set_initial_registers_sample (Ebl *ebl,
>      dwarf_regs[i] = 0x0;
>    for (i = 0; i < n_regs; i++)
>      {
> -      if (i > n_regs_mapping)
> +      if (i >= n_regs_mapping) /* TODO(REVIEW): off-by-one? */

This TODO comment can be removed and the assert.h and stdlib.h
#includes can be removed from aarch64_initreg_sample.c and
aarch64_initreg_sample.c. With these changes this series is ready to
be merged.

Aaron

>         break;
>        if (regs_mapping[i] < 0 || regs_mapping[i] >= (int)ebl->frame_nregs)
>         continue;
> --
> 2.53.0
>

Reply via email to