Description:
In case mysql_stmt_close was called after mysql_close works this branch of
mysql_stmt_close:
if (!(mysql= stmt->mysql))
{
if (!skip_free)
my_free((gptr) stmt, MYF(MY_WME));
DBUG_RETURN(0);
}
which just frees memory of the statement itself, and does not free stmt->mem_root and
stmt->query.
How to repeat:
Write any testcase with mysql_close before mysql_stmt_close and run it under valgrind.
Suggested fix:
- remove skip_free from mysql_stmt_close.
- from mysql_close() just walk through all open statements and set stmt->mysql= 0
We don't need to call server to close statement entity on server side, because it's done
automatically when connection is closed.
- rewrite branch with simple_command() in mysql_stmt_close() to work only if stmt->mysql
is not zero.
- make sure all cleanups are done whether connection is alive or not.
Description: In case mysql_stmt_close was called after mysql_close works this branch of mysql_stmt_close: if (!(mysql= stmt->mysql)) { if (!skip_free) my_free((gptr) stmt, MYF(MY_WME)); DBUG_RETURN(0); } which just frees memory of the statement itself, and does not free stmt->mem_root and stmt->query. How to repeat: Write any testcase with mysql_close before mysql_stmt_close and run it under valgrind. Suggested fix: - remove skip_free from mysql_stmt_close. - from mysql_close() just walk through all open statements and set stmt->mysql= 0 We don't need to call server to close statement entity on server side, because it's done automatically when connection is closed. - rewrite branch with simple_command() in mysql_stmt_close() to work only if stmt->mysql is not zero. - make sure all cleanups are done whether connection is alive or not.