Commit 4354cfd4 authored by He Zhenxing's avatar He Zhenxing

Backport BUG#38468 Memory leak detected when using mysqlbinlog utility

There were two memory leaks in mysqlbinlog command, one was already
fixed by previous patches, another one was that defaults_argv was
set to the value of argv after parse_args, in which called
handle_options after calling load_defaults and changed the value
of argv, and caused the memory allocated for defaults arguments
not freed.

Fixed the problem by setting defaults_argv right after calling
load_defaults.
parent 494adde6
...@@ -1346,7 +1346,6 @@ static int parse_args(int *argc, char*** argv) ...@@ -1346,7 +1346,6 @@ static int parse_args(int *argc, char*** argv)
int ho_error; int ho_error;
result_file = stdout; result_file = stdout;
load_defaults("my",load_default_groups,argc,argv);
if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option))) if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option)))
exit(ho_error); exit(ho_error);
if (debug_info_flag) if (debug_info_flag)
...@@ -1998,8 +1997,9 @@ int main(int argc, char** argv) ...@@ -1998,8 +1997,9 @@ int main(int argc, char** argv)
my_init_time(); // for time functions my_init_time(); // for time functions
load_defaults("my", load_default_groups, &argc, &argv);
defaults_argv= argv;
parse_args(&argc, (char***)&argv); parse_args(&argc, (char***)&argv);
defaults_argv=argv;
if (!argc) if (!argc)
{ {
......
...@@ -380,3 +380,27 @@ FLUSH LOGS; ...@@ -380,3 +380,27 @@ FLUSH LOGS;
--echo End of 5.0 tests --echo End of 5.0 tests
--echo End of 5.1 tests --echo End of 5.1 tests
#
# BUG#38468 Memory leak detected when using mysqlbinlog utility;
#
disable_query_log;
RESET MASTER;
CREATE TABLE t1 SELECT 1;
FLUSH LOGS;
DROP TABLE t1;
enable_query_log;
# Write an empty file for comparison
write_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn.empty;
EOF
# Before fix of BUG#38468, this would generate some warnings
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 >/dev/null 2> $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn
# Make sure the command above does not generate any error or warnings
diff_files $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn.empty;
# Cleanup for this part of test
remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn.empty;
remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment