Fix iov_len calculation in aarch64_linux_set_debug_regs
[external/binutils.git] / gdb / nat / aarch64-linux-hw-point.c
index 1a5fa6a..dcbfa98 100644 (file)
@@ -561,8 +561,8 @@ aarch64_linux_set_debug_regs (const struct aarch64_debug_reg_state *state,
   ctrl = watchpoint ? state->dr_ctrl_wp : state->dr_ctrl_bp;
   if (count == 0)
     return;
-  iov.iov_len = (offsetof (struct user_hwdebug_state, dbg_regs[count - 1])
-                + sizeof (regs.dbg_regs [count - 1]));
+  iov.iov_len = (offsetof (struct user_hwdebug_state, dbg_regs)
+                + count * sizeof (regs.dbg_regs[0]));
 
   for (i = 0; i < count; i++)
     {