Commit b440125f authored by 's avatar

Postfix bug#48321

Fix the memory leak
parent 28004bd5
......@@ -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
......
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