Merge pull request #547 from hmueller01/fix-memory-leak

make telnet connection more robust
This commit is contained in:
martin-ger
2025-02-05 20:22:11 +01:00
committed by GitHub
+7 -2
View File
@@ -782,6 +782,11 @@ void console_send_response(struct espconn *pespconn, uint8_t do_cmd)
{
uint16_t len = ringbuf_bytes_used(console_tx_buffer);
console_output = (char *)os_malloc(len + 4);
if (console_output == NULL)
{
os_printf("Heap overflow. Free: %d, Needed: %d\r\n", system_get_free_heap_size(), len + 4);
return;
}
ringbuf_memcpy_from(console_output, console_tx_buffer, len);
#if MQTT_CLIENT
@@ -804,9 +809,9 @@ void console_send_response(struct espconn *pespconn, uint8_t do_cmd)
else
{
UART_Send(0, console_output, len);
os_free(console_output);
console_output = NULL;
}
os_free(console_output);
console_output = NULL;
}
#if ALLOW_SCANNING