Commit e30a3048 authored by Monty's avatar Monty

Ensure that mysqlbinlog frees all memory at exit

parent 4f4a4cf9
......@@ -95,6 +95,7 @@ static uint opt_protocol= 0;
static FILE *result_file;
static char *result_file_name= 0;
static const char *output_prefix= "";
static char **defaults_argv= 0;
#ifndef DBUG_OFF
static const char *default_dbug_option = "d:t:o,/tmp/mariadb-binlog.trace";
......@@ -1893,13 +1894,26 @@ static void cleanup()
delete glob_description_event;
if (mysql)
mysql_close(mysql);
free_defaults(defaults_argv);
free_annotate_event();
my_free_open_file_info();
load_processor.destroy();
mysql_server_end();
DBUG_VOID_RETURN;
}
static void die()
{
cleanup();
my_end(MY_DONT_FREE_DBUG);
exit(1);
}
static void print_version()
{
printf("%s Ver 3.4 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE);
printf("%s Ver 3.5 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE);
}
......@@ -1930,7 +1944,7 @@ static my_time_t convert_str_to_timestamp(const char* str)
l_time.time_type != MYSQL_TIMESTAMP_DATETIME || status.warnings)
{
error("Incorrect date and time argument: %s", str);
exit(1);
die();
}
/*
Note that Feb 30th, Apr 31st cause no error messages and are mapped to
......@@ -1988,7 +2002,7 @@ get_one_option(const struct my_option *opt, char *argument, const char *)
opt->name)) <= 0)
{
sf_leaking_memory= 1; /* no memory leak reports here */
exit(1);
die();
}
break;
#ifdef WHEN_FLASHBACK_REVIEW_READY
......@@ -2013,7 +2027,7 @@ get_one_option(const struct my_option *opt, char *argument, const char *)
opt->name)) <= 0)
{
sf_leaking_memory= 1; /* no memory leak reports here */
exit(1);
die();
}
opt_base64_output_mode= (enum_base64_output_mode) (val - 1);
}
......@@ -2098,7 +2112,9 @@ static int parse_args(int *argc, char*** argv)
int ho_error;
if ((ho_error=handle_options(argc, argv, my_options, get_one_option)))
exit(ho_error);
{
die();
}
if (debug_info_flag)
my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO;
else if (debug_check_flag)
......@@ -3017,7 +3033,6 @@ static Exit_status dump_local_log_entries(PRINT_EVENT_INFO *print_event_info,
int main(int argc, char** argv)
{
char **defaults_argv;
Exit_status retval= OK_CONTINUE;
ulonglong save_stop_position;
MY_INIT(argv[0]);
......@@ -3068,7 +3083,7 @@ int main(int argc, char** argv)
if (!remote_opt)
{
error("The --raw mode only works with --read-from-remote-server");
exit(1);
die();
}
if (one_database)
warning("The --database option is ignored in raw mode");
......@@ -3090,7 +3105,7 @@ int main(int argc, char** argv)
O_WRONLY | O_BINARY, MYF(MY_WME))))
{
error("Could not create log file '%s'", result_file_name);
exit(1);
die();
}
}
else
......@@ -3211,11 +3226,6 @@ int main(int argc, char** argv)
if (result_file && result_file != stdout)
my_fclose(result_file, MYF(0));
cleanup();
free_annotate_event();
free_defaults(defaults_argv);
my_free_open_file_info();
load_processor.destroy();
mysql_server_end();
/* We cannot free DBUG, it is used in global destructors after exit(). */
my_end(my_end_arg | MY_DONT_FREE_DBUG);
......@@ -3225,7 +3235,6 @@ int main(int argc, char** argv)
err:
cleanup();
free_defaults(defaults_argv);
my_end(my_end_arg);
exit(retval == ERROR_STOP ? 1 : 0);
DBUG_RETURN(retval == ERROR_STOP ? 1 : 0);
......
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