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? */
        break;
       if (regs_mapping[i] < 0 || regs_mapping[i] >= (int)ebl->frame_nregs)
        continue;
-- 
2.53.0

Reply via email to