Commit 3bf1e07f authored by David McCurley's avatar David McCurley Committed by me-no-dev

WiFiUDF Low memory fix (#8065)

Fixed library crash on low memory where `new char[1460];` throws an exception.  `malloc` is a safe drop in replacement.
parent 5ebe01fd
...@@ -44,7 +44,7 @@ uint8_t WiFiUDP::begin(IPAddress address, uint16_t port){ ...@@ -44,7 +44,7 @@ uint8_t WiFiUDP::begin(IPAddress address, uint16_t port){
server_port = port; server_port = port;
tx_buffer = new char[1460]; tx_buffer = (char *)malloc(1460);
if(!tx_buffer){ if(!tx_buffer){
log_e("could not create tx buffer: %d", errno); log_e("could not create tx buffer: %d", errno);
return 0; return 0;
...@@ -100,7 +100,7 @@ uint8_t WiFiUDP::beginMulticast(IPAddress a, uint16_t p){ ...@@ -100,7 +100,7 @@ uint8_t WiFiUDP::beginMulticast(IPAddress a, uint16_t p){
void WiFiUDP::stop(){ void WiFiUDP::stop(){
if(tx_buffer){ if(tx_buffer){
delete[] tx_buffer; free(tx_buffer);
tx_buffer = NULL; tx_buffer = NULL;
} }
tx_buffer_len = 0; tx_buffer_len = 0;
...@@ -136,7 +136,7 @@ int WiFiUDP::beginPacket(){ ...@@ -136,7 +136,7 @@ int WiFiUDP::beginPacket(){
// allocate tx_buffer if is necessary // allocate tx_buffer if is necessary
if(!tx_buffer){ if(!tx_buffer){
tx_buffer = new char[1460]; tx_buffer = (char *)malloc(1460);
if(!tx_buffer){ if(!tx_buffer){
log_e("could not create tx buffer: %d", errno); log_e("could not create tx buffer: %d", errno);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment