nodemcu / nodemcu-firmware

Lua based interactive firmware for ESP8266, ESP8285 and ESP32

Home Page:https://nodemcu.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Memory leak on UART receive when len==0

LianYangCn opened this issue · comments

hi,

here,

switch(event.type) {
case UART_DATA: {
post = (uart_event_post_t*)malloc(sizeof(uart_event_post_t));
if(post == NULL) {
ESP_LOGE(UART_TAG, "Can not alloc memory in task_uart()");
// reboot here?
continue;
}
// Attempt to coalesce received bytes to reduce risk of overrunning
// the task event queue.
size_t len;
if (uart_get_buffered_data_len(id, &len) != ESP_OK)
len = event.size;
if (len == 0)
continue; // we already gobbled all the bytes
post->data = malloc(len);

Is here possible that len == 0 at line 118, if so, post (which malloc at line 107) will never be freed

commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

It will still be freed in king 168