Ensure that _size is properly set in begin (#2706)
* Ensure that _size is properly set in begin * NULL check on _data assignment * Changed _data to malloc in order to catch alloc fails
This commit is contained in:
parent
a0ad987029
commit
932666a03f
@ -130,7 +130,12 @@ bool EEPROMClass::begin(size_t size) {
|
|||||||
delete[] _data;
|
delete[] _data;
|
||||||
}
|
}
|
||||||
|
|
||||||
_data = new uint8_t[size];
|
_data = (uint8_t*) malloc(size);
|
||||||
|
if(!_data) {
|
||||||
|
log_e("Not enough memory for %d bytes in EEPROM");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
_size = size;
|
||||||
nvs_get_blob(_handle, _name, _data, &_size);
|
nvs_get_blob(_handle, _name, _data, &_size);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user