Skip to content

Commit

Permalink
target: Handle when target->detach() throws when freeing the target…
Browse files Browse the repository at this point in the history
…s list
  • Loading branch information
dragonmux committed Jul 5, 2024
1 parent 24decdc commit ed6e5b8
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/target/target.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,19 @@ void target_mem_map_free(target_s *target)

void target_list_free(void)
{
target_s *target = target_list;
target_s *volatile target = target_list;
while (target) {
target_s *next_target = target->next;
if (target->attached)
target->detach(target);
TRY (EXCEPTION_ALL) {
if (target->attached)
target->detach(target);
}
CATCH () {
default:
DEBUG_ERROR("Exception caught while detaching from target: %s\n", exception_frame.msg);
target->attached = false;
break;
}
if (target->tc && target->tc->destroy_callback)
target->tc->destroy_callback(target->tc, target);
if (target->priv)
Expand Down

0 comments on commit ed6e5b8

Please sign in to comment.