File tree 1 file changed +10
-3
lines changed
hardware/esp8266com/esp8266/libraries/EEPROM
1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ EEPROMClass::EEPROMClass()
41
41
42
42
void EEPROMClass::begin (size_t size)
43
43
{
44
- if (size < 0 )
44
+ if (size <= 0 )
45
45
return ;
46
46
if (size > SPI_FLASH_SEC_SIZE)
47
47
size = SPI_FLASH_SEC_SIZE;
@@ -60,8 +60,9 @@ void EEPROMClass::end()
60
60
return ;
61
61
62
62
commit ();
63
-
64
- delete[] _data;
63
+ if (_data) {
64
+ delete[] _data;
65
+ }
65
66
_data = 0 ;
66
67
_size = 0 ;
67
68
}
@@ -71,6 +72,8 @@ uint8_t EEPROMClass::read(int address)
71
72
{
72
73
if (address < 0 || (size_t )address >= _size)
73
74
return 0 ;
75
+ if (!_data)
76
+ return 0 ;
74
77
75
78
return _data[address];
76
79
}
@@ -79,6 +82,8 @@ void EEPROMClass::write(int address, uint8_t value)
79
82
{
80
83
if (address < 0 || (size_t )address >= _size)
81
84
return ;
85
+ if (!_data)
86
+ return ;
82
87
83
88
_data[address] = value;
84
89
_dirty = true ;
@@ -91,6 +96,8 @@ bool EEPROMClass::commit()
91
96
return false ;
92
97
if (!_dirty)
93
98
return true ;
99
+ if (!_data)
100
+ return false ;
94
101
95
102
noInterrupts ();
96
103
if (spi_flash_erase_sector (CONFIG_SECTOR) == SPI_FLASH_RESULT_OK) {
You can’t perform that action at this time.
0 commit comments