mirror of https://github.com/ARMmbed/mbed-os.git
SFDP: Fix sector map table allocation check
When passing an allocation size directly to `std::make_unique`, `std::nothrow` is unavailable, so any failed allocation results in an exception which we cannot catch because Mbed OS is compiled with `-fno-exceptions`. To fix this, chain `std::make_unique` with `new (std::nothrow)`, and the allocated `unique_ptr` retains the `nullptr` property.pull/14989/head
parent
7a8ff5f115
commit
2581254492
|
@ -256,7 +256,7 @@ int sfdp_parse_sector_map_table(Callback<int(bd_addr_t, void *, bd_size_t)> sfdp
|
||||||
* - regions in each configuration
|
* - regions in each configuration
|
||||||
* is variable -> the size of this table is variable
|
* is variable -> the size of this table is variable
|
||||||
*/
|
*/
|
||||||
auto smptbl_buff = std::make_unique<uint8_t[]>(sfdp_info.smptbl.size);
|
auto smptbl_buff = std::unique_ptr<uint8_t[]>(new (std::nothrow) uint8_t[sfdp_info.smptbl.size]);
|
||||||
if (!smptbl_buff) {
|
if (!smptbl_buff) {
|
||||||
tr_error("Failed to allocate memory");
|
tr_error("Failed to allocate memory");
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Reference in New Issue