Skip to content

Commit 5ab4b15

Browse files
committed
fix(mem): abort request on failed allocations
1 parent 3b6d29b commit 5ab4b15

File tree

6 files changed

+9
-0
lines changed

6 files changed

+9
-0
lines changed

src/AsyncJson.cpp

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,7 @@ void AsyncWebServerRequest::_parseMultipartPostByte(uint8_t data, bool last) {
542542
log_e("Failed to allocate buffer");
543543
#endif
544544
_multiParseState = PARSE_ERROR;
545+
abort();
545546
return;
546547
}
547548
_itemBufferIndex = 0;
@@ -1004,6 +1005,7 @@ void AsyncWebServerRequest::requestAuthentication(AsyncAuthType method, const ch
10041005
#ifdef ESP32
10051006
log_e("Failed to allocate buffer");
10061007
#endif
1008+
abort();
10071009
}
10081010

10091011
break;
@@ -1029,6 +1031,7 @@ void AsyncWebServerRequest::requestAuthentication(AsyncAuthType method, const ch
10291031
#ifdef ESP32
10301032
log_e("Failed to allocate buffer");
10311033
#endif
1034+
abort();
10321035
}
10331036
}
10341037
break;

src/WebResponses.cpp

Lines changed: 1 addition & 0 deletions
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)