memory leak on 'server_version' #17
Description
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.