From 4c138edff7212fd2662aee7546474e774c74306f Mon Sep 17 00:00:00 2001 From: stefanrueger Date: Mon, 24 Aug 2026 08:07:43 +0200 Subject: [PATCH] Fix jtag3_command() --- src/jtag3.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/jtag3.c b/src/jtag3.c index 430445c4..fb805323 100644 --- a/src/jtag3.c +++ b/src/jtag3.c @@ -805,7 +805,7 @@ int jtag3_command(const PROGRAMMER *pgm, unsigned char *cmd, unsigned int cmdlen return LIBAVRDUDE_GENERAL_FAILURE; } - if(status < 4 || !resp) { + if(status < 3 || !resp) { pmsg_error("%s(%s) failed owing to unexpected return\n", __func__, descr); mmt_free(*resp); *resp = NULL; @@ -820,7 +820,7 @@ int jtag3_command(const PROGRAMMER *pgm, unsigned char *cmd, unsigned int cmdlen } unsigned char code = (*resp)[1] & RSP3_STATUS_MASK; - int softfail = (*resp)[3] == RSP3_FAIL_OCD_LOCKED || (*resp)[3] == RSP3_FAIL_CRC_FAILURE; + int softfail = status > 3 && ((*resp)[3] == RSP3_FAIL_OCD_LOCKED || (*resp)[3] == RSP3_FAIL_CRC_FAILURE); if(code != RSP3_OK) { if(code == RSP3_FAILED && softfail) pmsg_error("device is locked; chip erase required to unlock\n");