Skip to content

Commit 2d39bcb

Browse files
Adam5Wudevyte
authored andcommitted
Resolve updater size check bug (#4550)
1 parent 559cb35 commit 2d39bcb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

cores/esp8266/Updater.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ bool UpdaterClass::begin(size_t size, int command) {
8686
//size of the update rounded to a sector
8787
uint32_t roundedSize = (size + FLASH_SECTOR_SIZE - 1) & (~(FLASH_SECTOR_SIZE - 1));
8888
//address where we will start writing the update
89-
updateStartAddress = updateEndAddress - roundedSize;
89+
updateStartAddress = (updateEndAddress > roundedSize)? (updateEndAddress - roundedSize) : 0;
9090

9191
#ifdef DEBUG_UPDATER
9292
DEBUG_UPDATER.printf("[begin] roundedSize: 0x%08X (%d)\n", roundedSize, roundedSize);
@@ -390,4 +390,4 @@ void UpdaterClass::printError(Print &out){
390390
}
391391
}
392392

393-
UpdaterClass Update;
393+
UpdaterClass Update;

0 commit comments

Comments
 (0)