From afd0ca23a09a2896a73c65a4c0aa014d3602c093 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Wed, 5 Aug 2015 09:00:17 -0400 Subject: [PATCH] EEPROM: round requested size to 4 byte boundary (#659) --- libraries/EEPROM/EEPROM.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libraries/EEPROM/EEPROM.cpp b/libraries/EEPROM/EEPROM.cpp index dfd968a4a..41c484306 100644 --- a/libraries/EEPROM/EEPROM.cpp +++ b/libraries/EEPROM/EEPROM.cpp @@ -1,9 +1,9 @@ -/* +/* EEPROM.cpp - esp8266 EEPROM emulation Copyright (c) 2014 Ivan Grokhotkov. All rights reserved. This file is part of the esp8266 core for Arduino environment. - + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either @@ -34,7 +34,7 @@ EEPROMClass::EEPROMClass(uint32_t sector) : _sector(sector) , _data(0) , _size(0) -, _dirty(false) +, _dirty(false) { } @@ -44,6 +44,8 @@ void EEPROMClass::begin(size_t size) { if (size > SPI_FLASH_SEC_SIZE) size = SPI_FLASH_SEC_SIZE; + size = (size + 3) & (~3); + if (_data) { delete[] _data; }