From c43c1287895c2f447fbc061504f74e5c0bb707a1 Mon Sep 17 00:00:00 2001 From: ALTracer <11005378+ALTracer@users.noreply.github.com> Date: Sun, 18 Aug 2024 18:00:23 +0300 Subject: [PATCH] target_flash: Prevent NULL dereference when detached from targets --- src/target/target_flash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/target_flash.c b/src/target/target_flash.c index f20b7042d1b..2d744937634 100644 --- a/src/target/target_flash.c +++ b/src/target/target_flash.c @@ -300,7 +300,7 @@ bool target_flash_write(target_s *target, target_addr_t dest, const void *src, s bool target_flash_complete(target_s *target) { - if (!target->flash_mode) + if (!target || !target->flash_mode) return false; bool result = true; /* Catch false returns with &= */