Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible error in out_buffer free memory #13

Open
hdrut opened this issue Apr 20, 2018 · 0 comments
Open

Possible error in out_buffer free memory #13

hdrut opened this issue Apr 20, 2018 · 0 comments

Comments

@hdrut
Copy link

hdrut commented Apr 20, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant