mariadb/client
Luis Soares fbf595d0fb BUG#48993: valgrind errors in mysqlbinlog
I found three issues during the analysis:
 1. Memory leak caused by temp_buf not being freed;
 2. Memory leak caused when handling argv;
 3. Conditional jump that depended on unitialized values.

Issue #1
--------

  DESCRIPTION: when mysqlbinlog is reading from a remote location
  the event temp_buf references the incoming stream (in NET
  object), which is not freed by mysqlbinlog explicitly. On the
  other hand, when it is reading local binary log, it points to a
  temporary buffer that needs to be explicitly freed. For both
  cases, the temp_buf was not freed by mysqlbinlog, instead was
  set to 0.  This clearly disregards the free required in the
  second case, thence creating a memory leak.

  FIX: we make temp_buf to be conditionally freed depending on
  the value of remote_opt. Found out that similar fix is already
  in most recent codebases.

Issue #2 
--------

  DESCRIPTION: load_defaults is called by parse_args, and it
  reads default options from configuration files and put them
  BEFORE the arguments that are already in argc and argv. This is
  done resorting to MEM_ROOT. However, parse_args calls
  handle_options immediately after which changes argv. Later when
  freeing the defaults, pointers to MEM_ROOT won't match, causing
  the memory not to be freed:

  void free_defaults(char **argv)
  {
    MEM_ROOT ptr
    memcpy_fixed((char*) &ptr,(char *) argv - sizeof(ptr), sizeof(ptr));
    free_root(&ptr,MYF(0));
  }

  FIX: we remove load_defaults from parse_args and call it
  before. Then we save argv with defaults in defaults_argv BEFORE
  calling parse_args (which inside can then call handle_options
  at will). Actually, found out that this is in fact kind of a
  backport for BUG#38468 into 5.1, so I merged in the test case
  as well and added error check for load_defaults call.

  Fix based on:
  revid:zhenxing.he@sun.com-20091002081840-uv26f0flw4uvo33y


Issue #3 
--------

  DESCRIPTION: the structure st_print_event_info constructor
  would not initialize the sql_mode member, although it did for
  sql_mode_inited (set to false). This would later raise the
  warning in valgrind when printing the sql_mode in the event
  header, as this print out is protected by a check against
  sql_mode_inited and sql_mode variables. Given that sql_mode was
  not initialized valgrind would output the warning.

  FIX: we add initialization of sql_mode to the
  st_print_event_info constructor.
2010-02-17 18:07:28 +00:00
..
.cvsignore Import changeset 2000-07-31 21:29:14 +02:00
client_priv.h WL#5182 Remove more deprecated 4.1/5.0 features 2010-01-27 13:23:28 +01:00
CMakeLists.txt Addition to Fix for BUG#46591 - .frm file isn't sync'd with sync_frm enabled 2009-09-04 11:19:44 +05:30
completion_hash.cc WL#3817: Simplify string / memory area types and make things more consistent (first part) 2007-05-10 12:59:39 +03:00
completion_hash.h my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
echo.c echo.c: 2007-03-20 18:31:49 +01:00
get_password.c fixes for build failures due to my yesterday's changeset forbidding 2008-02-19 18:45:11 +01:00
Makefile.am Fix for BUG#46591 - .frm file isn't sync'd with sync_frm enabled for 2009-09-03 16:02:03 +05:30
my_readline.h Manual merge. 2009-03-18 11:27:49 +03:00
mysql.cc Recommit of Bug#49447. 2010-02-04 13:39:42 +01:00
mysql_upgrade.c Recommit of Bug#49447. 2010-02-04 13:39:42 +01:00
mysqladmin.cc Recommit of Bug#49447. 2010-02-04 13:39:42 +01:00
mysqlbinlog.cc BUG#48993: valgrind errors in mysqlbinlog 2010-02-17 18:07:28 +00:00
mysqlcheck.c Recommit of Bug#49447. 2010-02-04 13:39:42 +01:00
mysqldump.c Recommit of Bug#49447. 2010-02-04 13:39:42 +01:00
mysqlimport.c Recommit of Bug#49447. 2010-02-04 13:39:42 +01:00
mysqlshow.c Recommit of Bug#49447. 2010-02-04 13:39:42 +01:00
mysqlslap.c Recommit of Bug#49447. 2010-02-04 13:39:42 +01:00
mysqltest.cc Recommit of Bug#49447. 2010-02-04 13:39:42 +01:00
readline.cc Manual merge. 2009-03-18 11:27:49 +03:00
sql_string.cc auto-merge 2009-03-19 09:44:58 -04:00
sql_string.h Fixed compiler warnings 2007-02-23 13:13:55 +02:00