Skip to content

Commit bf9f457

Browse files
committed
Log a warning is cbuf reallocation fails
1 parent 89931c1 commit bf9f457

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/WebResponses.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,14 @@ size_t AsyncResponseStream::write(const uint8_t *data, size_t len) {
840840
if (len > _content->room()) {
841841
size_t needed = len - _content->room();
842842
_content->resizeAdd(needed);
843+
// log a warning if allocation failed, but do not return: keep writing the bytes we can
844+
// with _content->write: if len is more than the available size in the buffer, only
845+
// the available size will be written
846+
if (len > _content->room()) {
847+
#ifdef ESP32
848+
log_e("Failed to allocate");
849+
#endif
850+
}
843851
}
844852
size_t written = _content->write((const char *)data, len);
845853
_contentLength += written;

0 commit comments

Comments
 (0)