ESP8266MQTTClient icon indicating copy to clipboard operation
ESP8266MQTTClient copied to clipboard

Possible error in out_buffer free memory

Open hdrut opened this issue 6 years ago • 0 comments

Hi, I see in ESP8266MQTTClient.cpp the following memory allocations for in and out buffers:

_state.in_buffer = (uint8_t *)malloc(DEFAULT_MQTT_BUFFER_SIZE_BYTES);
if(_state.in_buffer == NULL) {
    LOG("Not enought memory\r\n");
    return false;
}
_state.in_buffer_length = DEFAULT_MQTT_BUFFER_SIZE_BYTES;
_state.out_buffer = (uint8_t *)malloc(DEFAULT_MQTT_BUFFER_SIZE_BYTES);
if(_state.in_buffer == NULL) {
    free(_state.in_buffer);
    LOG("Not enought memory\r\n");
    return false;
}

I believe the last check over in_buffer should be done over out_buffer, and also both mallocs() should be freed. Please correct me if i'm wrong...

Thanks, rgds,

Richard

hdrut avatar Apr 20 '18 13:04 hdrut