Skip to content

Commit 1e01368

Browse files
Add check so that FlashIAP does not allocate memory on flash_init failure.
1 parent fc5f325 commit 1e01368

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

drivers/source/FlashIAP.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,13 @@ 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+
{
66+
uint32_t page_size = get_page_size();
67+
_page_buf = new uint8_t[page_size];
68+
}
6469

6570
_mutex->unlock();
6671
return ret;

0 commit comments

Comments
 (0)