From 7f0d7f29d39d19f553fb6b8ec1ac0cd8374c37a5 Mon Sep 17 00:00:00 2001 From: Alistair Popple Date: Thu, 9 Aug 2018 17:10:58 +1000 Subject: libpdbg/chip.c: Fix logic error attempting to restore r0 and r1 When instruction ramming fails we attempt to restore r0 and r1. This is unlikely to work as instruction ramming isn't likely to magically start working if a previous attempt failed. Therefore it is only attempted once before bailing. However a logic bug in the code meant it would try indefinitely. Signed-off-by: Alistair Popple --- libpdbg/chip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libpdbg/chip.c') diff --git a/libpdbg/chip.c b/libpdbg/chip.c index 079592c..5acda73 100644 --- a/libpdbg/chip.c +++ b/libpdbg/chip.c @@ -188,7 +188,7 @@ static int ram_instructions(struct pdbg_target *thread_target, uint64_t *opcodes if (thread->ram_instruction(thread, opcode, &scratch)) { PR_DEBUG("%s: %d, %016" PRIx64 "\n", __FUNCTION__, __LINE__, opcode); exception = 1; - if (i >= 0 || i < len) + if (i >= 0 && i < len) /* skip the rest and attempt to restore r0 and r1 */ i = len - 1; else -- cgit v1.2.1