From 2d39bcba7d8b76d4bee1c76f3ba878d6c3ad1b2b Mon Sep 17 00:00:00 2001 From: Zhenyu Wu Date: Fri, 23 Mar 2018 14:01:17 -0400 Subject: [PATCH] Resolve updater size check bug (#4550) --- cores/esp8266/Updater.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cores/esp8266/Updater.cpp b/cores/esp8266/Updater.cpp index 2a93d96d7..e01eca0bc 100644 --- a/cores/esp8266/Updater.cpp +++ b/cores/esp8266/Updater.cpp @@ -86,7 +86,7 @@ bool UpdaterClass::begin(size_t size, int command) { //size of the update rounded to a sector uint32_t roundedSize = (size + FLASH_SECTOR_SIZE - 1) & (~(FLASH_SECTOR_SIZE - 1)); //address where we will start writing the update - updateStartAddress = updateEndAddress - roundedSize; + updateStartAddress = (updateEndAddress > roundedSize)? (updateEndAddress - roundedSize) : 0; #ifdef DEBUG_UPDATER DEBUG_UPDATER.printf("[begin] roundedSize: 0x%08X (%d)\n", roundedSize, roundedSize); @@ -390,4 +390,4 @@ void UpdaterClass::printError(Print &out){ } } -UpdaterClass Update; \ No newline at end of file +UpdaterClass Update;