Skip to content

Commit e84bcd1

Browse files
committed
fix(mem): abort request on failed allocations
1 parent 17da372 commit e84bcd1

6 files changed

+9
-0
lines changed

src/AsyncJson.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ void AsyncCallbackJsonWebHandler::handleBody(AsyncWebServerRequest *request, uin
154154
#ifdef ESP32
155155
log_e("Failed to allocate buffer");
156156
#endif
157+
request->abort();
157158
return;
158159
}
159160
}

src/AsyncMessagePack.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ void AsyncCallbackMessagePackWebHandler::handleBody(AsyncWebServerRequest *reque
106106
#ifdef ESP32
107107
log_e("Failed to allocate buffer");
108108
#endif
109+
request->abort();
109110
return;
110111
}
111112
}

src/AsyncWebSocket.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ size_t webSocketSendFrame(AsyncClient *client, bool final, uint8_t opcode, bool
6969
#ifdef ESP32
7070
log_e("Failed to allocate buffer");
7171
#endif
72+
client->abort();
7273
return 0;
7374
}
7475

@@ -523,6 +524,7 @@ void AsyncWebSocketClient::close(uint16_t code, const char *message) {
523524
} else {
524525
#ifdef ESP32
525526
log_e("Failed to allocate buffer");
527+
_client->abort();
526528
#endif
527529
}
528530
}

src/WebHandlers.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ bool AsyncStaticWebHandler::_searchFile(AsyncWebServerRequest *request, const St
176176
#ifdef ESP32
177177
log_e("Failed to allocate buffer");
178178
#endif
179+
request->abort();
179180
request->_tempFile.close();
180181
return false;
181182
}

src/WebRequest.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,7 @@ void AsyncWebServerRequest::_parseMultipartPostByte(uint8_t data, bool last) {
534534
log_e("Failed to allocate buffer");
535535
#endif
536536
_multiParseState = PARSE_ERROR;
537+
abort();
537538
return;
538539
}
539540
_itemBufferIndex = 0;
@@ -993,6 +994,7 @@ void AsyncWebServerRequest::requestAuthentication(AsyncAuthType method, const ch
993994
#ifdef ESP32
994995
log_e("Failed to allocate buffer");
995996
#endif
997+
abort();
996998
}
997999

9981000
break;
@@ -1018,6 +1020,7 @@ void AsyncWebServerRequest::requestAuthentication(AsyncAuthType method, const ch
10181020
#ifdef ESP32
10191021
log_e("Failed to allocate buffer");
10201022
#endif
1023+
abort();
10211024
}
10221025
}
10231026
break;

src/WebResponses.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ size_t AsyncAbstractResponse::_ack(AsyncWebServerRequest *request, size_t len, u
411411
#ifdef ESP32
412412
log_e("Failed to allocate buffer");
413413
#endif
414+
request->abort();
414415
return 0;
415416
}
416417

0 commit comments

Comments
 (0)