From 6a9b2b82244057e2146929acf7ba296bce4eeab4 Mon Sep 17 00:00:00 2001 From: Uwe Bonnes Date: Sun, 23 Jan 2022 16:55:38 +0100 Subject: [PATCH] hosted/ftdi: Fix bad length calculation in MPSSE case of swdptap_seq_in() --- src/platforms/hosted/libftdi_swdptap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/platforms/hosted/libftdi_swdptap.c b/src/platforms/hosted/libftdi_swdptap.c index 4878437..3bf6989 100644 --- a/src/platforms/hosted/libftdi_swdptap.c +++ b/src/platforms/hosted/libftdi_swdptap.c @@ -305,7 +305,10 @@ static uint32_t swdptap_seq_in(int ticks) if (do_mpsse) { uint8_t DO[4]; libftdi_jtagtap_tdi_tdo_seq(DO, 0, NULL, ticks); - for (int i = 0; i < (ticks >> 3) + (ticks & 7)? 1: 0; i++) { + int bytes = ticks >> 3; + if (ticks & 7) + bytes++; + for (int i = 0; i < bytes; i++) { result |= DO[i] << (8 * i); } } else {