Skip to content

Commit

Permalink
lpc43xx: Fixed a bug in lpc43x0_detach() which leads to a crash via N…
Browse files Browse the repository at this point in the history
…ULL dereference when Flash detection fails
  • Loading branch information
dragonmux authored and esden committed Jul 26, 2023
1 parent 2cc1b94 commit 2677a24
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/target/lpc43xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -680,10 +680,12 @@ static bool lpc43x0_attach(target_s *const target)
static void lpc43x0_detach(target_s *const target)
{
lpc43x0_priv_s *const priv = (lpc43x0_priv_s *)target->target_storage;
free(priv->flash->flash_high);
free(priv->flash);
priv->flash = NULL;
target->flash = NULL;
if (priv->flash) {
free(priv->flash->flash_high);
free(priv->flash);
priv->flash = NULL;
target->flash = NULL;
}
cortexm_detach(target);
}

Expand Down

0 comments on commit 2677a24

Please sign in to comment.