Skip to content

Commit 405b238

Browse files
committed
Fix short unaligned writes in SPIFFS HAL (#924)
1 parent f328e66 commit 405b238

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

cores/esp8266/spiffs_hal.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ int32_t spiffs_hal_write(uint32_t addr, uint32_t size, uint8_t *src) {
110110

111111
if (addr < alignedBegin) {
112112
uint32_t nb = alignedBegin - addr;
113+
if (nb > size)
114+
nb = size;
113115
uint32_t tmp = 0xffffffff;
114116
memcpy(((uint8_t* )&tmp) + 4 - nb, src, nb);
115117
if (!ESP.flashWrite(alignedBegin - 4, &tmp, 4)) {

0 commit comments

Comments
 (0)