Skip to content

Commit b3ba80d

Browse files
lbernstoneme-no-dev
authored andcommitted
nvs_handle is an int, was assigning NULL. Also cleaned up end to ensure no memory leak. (#3246)
1 parent a5935ce commit b3ba80d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Diff for: libraries/EEPROM/src/EEPROM.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include <esp_log.h>
3030

3131
EEPROMClass::EEPROMClass(void)
32-
: _handle(NULL)
32+
: _handle(0)
3333
, _data(0)
3434
, _size(0)
3535
, _dirty(false)
@@ -40,7 +40,7 @@ EEPROMClass::EEPROMClass(void)
4040

4141
EEPROMClass::EEPROMClass(uint32_t sector)
4242
// Only for compatiility, no sectors in nvs!
43-
: _handle(NULL)
43+
: _handle(0)
4444
, _data(0)
4545
, _size(0)
4646
, _dirty(false)
@@ -50,7 +50,7 @@ EEPROMClass::EEPROMClass(uint32_t sector)
5050
}
5151

5252
EEPROMClass::EEPROMClass(const char* name, uint32_t user_defined_size)
53-
: _handle(NULL)
53+
: _handle(0)
5454
, _data(0)
5555
, _size(0)
5656
, _dirty(false)
@@ -60,7 +60,7 @@ EEPROMClass::EEPROMClass(const char* name, uint32_t user_defined_size)
6060
}
6161

6262
EEPROMClass::~EEPROMClass() {
63-
// end();
63+
end();
6464
}
6565

6666
bool EEPROMClass::begin(size_t size) {
@@ -152,6 +152,9 @@ void EEPROMClass::end() {
152152
}
153153
_data = 0;
154154
_size = 0;
155+
156+
nvs_close(_handle);
157+
_handle = 0;
155158
}
156159

157160
uint8_t EEPROMClass::read(int address) {

0 commit comments

Comments
 (0)