Fixed exception when using Flash strings as object keys (fixes #784)

This commit is contained in:
Benoit Blanchon
2018-07-19 17:22:28 +02:00
parent d53a93e0ae
commit 3f666bd5f0
3 changed files with 7 additions and 2 deletions

View File

@ -15,7 +15,7 @@ class FixedSizeFlashString {
bool equals(const char* expected) const {
const char* actual = reinterpret_cast<const char*>(_str);
if (!actual || !expected) return actual == expected;
return strcmp_P(actual, expected) == 0;
return strncmp_P(expected, actual, _size) == 0;
}
bool is_null() const {

View File

@ -14,7 +14,7 @@ class ZeroTerminatedFlashString {
bool equals(const char* expected) const {
const char* actual = reinterpret_cast<const char*>(_str);
if (!actual || !expected) return actual == expected;
return strcmp_P(actual, expected) == 0;
return strcmp_P(expected, actual) == 0;
}
bool is_null() const {