Skip to content

Commit ea3761f

Browse files
authored
Merge pull request #12531 from dustin-crossman/pr/flashiap_fix
Add check so that FlashIAP does not allocate memory on flash_init failure
2 parents aa6fd58 + 2f97c2d commit ea3761f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/source/FlashIAP.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,12 @@ int FlashIAP::init()
5959
ret = -1;
6060
}
6161
}
62-
uint32_t page_size = get_page_size();
63-
_page_buf = new uint8_t[page_size];
62+
63+
// Do not allocate if flash_init failed
64+
if (ret == 0) {
65+
uint32_t page_size = get_page_size();
66+
_page_buf = new uint8_t[page_size];
67+
}
6468

6569
_mutex->unlock();
6670
return ret;

0 commit comments

Comments
 (0)