Skip to content

Commit fbe58b7

Browse files
committed
WiFiClientSecure: don't panic if memory allocation fails
If it fails due to a malloc somewhere in bigint.c, we will still crash (although with a less obvious crash message). If it fails in increase_bm_data_size, axTLS will handle this and report that connection has been aborted. This error will be passed on to the user, so that an application can recover and attempt to reconnect.
1 parent fcf9c0d commit fbe58b7

File tree

1 file changed

+0
-8
lines changed

1 file changed

+0
-8
lines changed

libraries/ESP8266WiFi/src/WiFiClientSecure.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -532,10 +532,8 @@ extern "C" int ax_get_file(const char *filename, uint8_t **buf) {
532532

533533
extern "C" void* ax_port_malloc(size_t size, const char* file, int line) {
534534
void* result = malloc(size);
535-
536535
if (result == nullptr) {
537536
DEBUG_TLS_MEM_PRINT("%s:%d malloc %d failed, left %d\r\n", file, line, size, ESP.getFreeHeap());
538-
panic();
539537
}
540538
if (size >= 1024) {
541539
DEBUG_TLS_MEM_PRINT("%s:%d malloc %d, left %d\r\n", file, line, size, ESP.getFreeHeap());
@@ -553,7 +551,6 @@ extern "C" void* ax_port_realloc(void* ptr, size_t size, const char* file, int l
553551
void* result = realloc(ptr, size);
554552
if (result == nullptr) {
555553
DEBUG_TLS_MEM_PRINT("%s:%d realloc %d failed, left %d\r\n", file, line, size, ESP.getFreeHeap());
556-
panic();
557554
}
558555
if (size >= 1024) {
559556
DEBUG_TLS_MEM_PRINT("%s:%d realloc %d, left %d\r\n", file, line, size, ESP.getFreeHeap());
@@ -563,9 +560,4 @@ extern "C" void* ax_port_realloc(void* ptr, size_t size, const char* file, int l
563560

564561
extern "C" void ax_port_free(void* ptr) {
565562
free(ptr);
566-
uint32_t *p = (uint32_t*) ptr;
567-
size_t size = p[-3];
568-
if (size >= 1024) {
569-
DEBUG_TLS_MEM_PRINT("free %d, left %d\r\n", p[-3], ESP.getFreeHeap());
570-
}
571563
}

0 commit comments

Comments
 (0)