Merge pull request #12531 from dustin-crossman/pr/flashiap_fix

Add check so that FlashIAP does not allocate memory on flash_init failure
pull/12594/head
Martin Kojtal 2020-03-05 15:36:57 +00:00 committed by GitHub
commit ea3761f38d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -59,8 +59,12 @@ int FlashIAP::init()
ret = -1;
}
}
uint32_t page_size = get_page_size();
_page_buf = new uint8_t[page_size];
// Do not allocate if flash_init failed
if (ret == 0) {
uint32_t page_size = get_page_size();
_page_buf = new uint8_t[page_size];
}
_mutex->unlock();
return ret;