Skip to content
This repository was archived by the owner on Jan 29, 2023. It is now read-only.
This repository was archived by the owner on Jan 29, 2023. It is now read-only.

memory leak on 'server_version' #17

Closed
@pabloandresm

Description

@pabloandresm

If you use .connect() with the correct database server, but wrong user credentials, the .connect() does "server_version=malloc()" when it calls parse_handshake_packet(), but as the user is wrong, it exits, without calling the "free(server_version)".

This free(server_version) is only called at the end of the .connect().

So the bug is when the .connect() exists after parse_handshake_packet(), missing the correspondent free(server_version) at all possible exits.

A workaround for this is:
MySQL_Connection->server_version=NULL;
bool res = MySQL_Connection->connect(...);
if (res==false)
if (MySQL_Connection->server_version)
free(MySQL_Connection->server_version);

To reproduce is easy. Perform a .connect() in a loop, pointing to a correct mariadb, but with unknown user/password.
In that loop show ESP.getFreeHeap(), and you will see the memory leak.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions