Hi Serhei,

On Tue, Mar 24, 2026 at 6:37 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.
> ---
>  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 0cf264b0..27428b0b 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? */

I believe >= is correct.  This is similar to the fix needed for the
regs[n_regs] bug in patch 1.

Aaron

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

Reply via email to