Skip to content

Commit

Permalink
Fixed a crash problem when not enough memory is available. (for ESP32)
Browse files Browse the repository at this point in the history
  • Loading branch information
lovyan03 committed Aug 9, 2023
1 parent 9afd717 commit 460fe47
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/lgfx/v1/platforms/esp32/Bus_SPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,10 +425,13 @@ namespace lgfx
len = (limit << 1) <= length ? limit : length;
if (limit <= 256) limit <<= 1;
auto dmabuf = _flip_buffer.getBuffer(len * bytes);
if (dmabuf == nullptr) {
break;
}
param->fp_copy(dmabuf, 0, len, param);
writeBytes(dmabuf, len * bytes, true, true);
} while (length -= len);
return;
if (length == 0) return;
}

/// ESP32-C3 で HIGHPART を使用すると異常動作するため分岐する;
Expand Down Expand Up @@ -532,10 +535,12 @@ namespace lgfx
{
if (false == use_dma && length < 1024)
{
use_dma = true;
auto buf = _flip_buffer.getBuffer(length);
memcpy(buf, data, length);
data = buf;
if (buf) {
memcpy(buf, data, length);
data = buf;
use_dma = true;
}
}
if (use_dma)
{
Expand Down

0 comments on commit 460fe47

Please sign in to comment.