summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <Li-Bing.Song@sun.com>2010-07-08 10:44:26 +0800
committerunknown <Li-Bing.Song@sun.com>2010-07-08 10:44:26 +0800
commit625ae7185abcfc7042be225d4f8ef77806fc0803 (patch)
tree9f60ddbecfa435fac34220f4cb78cc209e76c160 /sql
parentd9e7c4efb6bfebf625af629b3ca878f1d0dc7e02 (diff)
downloadmariadb-git-625ae7185abcfc7042be225d4f8ef77806fc0803.tar.gz
Postfix bug#48321
Fix the memory leak
Diffstat (limited to 'sql')
-rw-r--r--sql/log_event.cc20
1 files changed, 17 insertions, 3 deletions
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 0e4d4bd512b..93d170e1510 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -2396,6 +2396,8 @@ bool Query_log_event::write(IO_CACHE* file)
Query_log_event::Query_log_event()
:Log_event(), data_buf(0)
{
+ memset(&user, 0, sizeof(user));
+ memset(&host, 0, sizeof(host));
}
@@ -2438,6 +2440,9 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg,
{
time_t end_time;
+ memset(&user, 0, sizeof(user));
+ memset(&host, 0, sizeof(host));
+
error_code= errcode;
time(&end_time);
@@ -2783,13 +2788,13 @@ Query_log_event::Query_log_event(const char* buf, uint event_len,
CHECK_SPACE(pos, end, 1);
user.length= *pos++;
CHECK_SPACE(pos, end, user.length);
- user.str= my_strndup((const char *)pos, user.length, MYF(0));
+ user.str= (char *)pos;
pos+= user.length;
CHECK_SPACE(pos, end, 1);
host.length= *pos++;
CHECK_SPACE(pos, end, host.length);
- host.str= my_strndup((const char *)pos, host.length, MYF(0));
+ host.str= (char *)pos;
pos+= host.length;
}
default:
@@ -2805,12 +2810,16 @@ Query_log_event::Query_log_event(const char* buf, uint event_len,
time_zone_len + 1 +
data_len + 1 +
QUERY_CACHE_FLAGS_SIZE +
+ user.length + 1 +
+ host.length + 1 +
db_len + 1,
MYF(MY_WME))))
#else
if (!(start= data_buf = (Log_event::Byte*) my_malloc(catalog_len + 1 +
time_zone_len + 1 +
- data_len + 1,
+ data_len + 1 +
+ user.length + 1 +
+ host.length + 1,
MYF(MY_WME))))
#endif
DBUG_VOID_RETURN;
@@ -2833,6 +2842,11 @@ Query_log_event::Query_log_event(const char* buf, uint event_len,
if (time_zone_len)
copy_str_and_move(&time_zone_str, &start, time_zone_len);
+ if (user.length > 0)
+ copy_str_and_move((const char **)&(user.str), &start, user.length);
+ if (host.length > 0)
+ copy_str_and_move((const char **)&(host.str), &start, host.length);
+
/**
if time_zone_len or catalog_len are 0, then time_zone and catalog
are uninitialized at this point. shouldn't they point to the