Gracefully handle out of memory

This commit is contained in:
andig 2016-04-06 18:49:32 +02:00
parent e871a222fc
commit 9a291c876c
1 changed files with 4 additions and 0 deletions

View File

@ -267,6 +267,10 @@ size_t AsyncAbstractResponse::_ack(AsyncWebServerRequest *request, size_t len, u
outLen = (remaining > space)?space:remaining;
}
uint8_t *buf = (uint8_t *)malloc(outLen);
if (!buf) {
// os_printf("_ack malloc %d failed\n", outLen);
return 0;
}
if(_chunked){
readLen = _fillBuffer(buf, outLen - 8);