From 02b2fdb2aef56f08070504d915876bad38e61603 Mon Sep 17 00:00:00 2001 From: "David R. Piegdon" Date: Mon, 24 Jun 2019 02:25:36 +0000 Subject: [PATCH] fix overwriting of still-needed value (refs #487) this fixes a bug that was introduced in blackmagic PR #475 which lead to firmware crashes when connecting to a BMP more than once without a power-cycle. --- src/target/target.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/target/target.c b/src/target/target.c index 092673c..ed5f36c 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -110,8 +110,9 @@ void target_add_commands(target *t, const struct command_s *cmds, const char *na } if (t->commands) { - for (tc = t->commands; tc->next; tc = tc->next); - tc->next = tc; + struct target_command_s *tail; + for (tail = t->commands; tail->next; tail = tail->next); + tail->next = tc; } else { t->commands = tc; }