Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 932666a

Browse files
lbernstoneme-no-dev
authored andcommitted
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
1 parent a0ad987 commit 932666a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

‎libraries/EEPROM/src/EEPROM.cpp‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,12 @@ bool EEPROMClass::begin(size_t size) {
130130
delete[] _data;
131131
}
132132

133-
_data = new uint8_t[size];
133+
_data = (uint8_t*) malloc(size);
134+
if(!_data) {
135+
log_e("Not enough memory for %d bytes in EEPROM");
136+
return false;
137+
}
138+
_size = size;
134139
nvs_get_blob(_handle, _name, _data, &_size);
135140
return true;
136141
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /