mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-13 13:01:55 +03:00
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.
This commit is contained in:
@ -532,10 +532,8 @@ extern "C" int ax_get_file(const char *filename, uint8_t **buf) {
|
||||
|
||||
extern "C" void* ax_port_malloc(size_t size, const char* file, int line) {
|
||||
void* result = malloc(size);
|
||||
|
||||
if (result == nullptr) {
|
||||
DEBUG_TLS_MEM_PRINT("%s:%d malloc %d failed, left %d\r\n", file, line, size, ESP.getFreeHeap());
|
||||
panic();
|
||||
}
|
||||
if (size >= 1024) {
|
||||
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
|
||||
void* result = realloc(ptr, size);
|
||||
if (result == nullptr) {
|
||||
DEBUG_TLS_MEM_PRINT("%s:%d realloc %d failed, left %d\r\n", file, line, size, ESP.getFreeHeap());
|
||||
panic();
|
||||
}
|
||||
if (size >= 1024) {
|
||||
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
|
||||
|
||||
extern "C" void ax_port_free(void* ptr) {
|
||||
free(ptr);
|
||||
uint32_t *p = (uint32_t*) ptr;
|
||||
size_t size = p[-3];
|
||||
if (size >= 1024) {
|
||||
DEBUG_TLS_MEM_PRINT("free %d, left %d\r\n", p[-3], ESP.getFreeHeap());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user