Skip to content

Commit aea440d

Browse files
committed
Fixed mysqld_list_processes to remove a possibility to access null pointers
1 parent 809a0ce commit aea440d

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

sql/sql_show.cc

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2943,25 +2943,27 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose)
29432943

29442944
while (thread_info *thd_info= arg.thread_infos.get())
29452945
{
2946+
const char *str;
2947+
ulonglong start_time;
2948+
CSET_STRING query;
2949+
29462950
protocol->prepare_for_resend();
29472951
protocol->store(thd_info->thread_id);
29482952
protocol->store(thd_info->user, strlen(thd_info->user), system_charset_info);
29492953
protocol->store(thd_info->host, strlen(thd_info->host), system_charset_info);
29502954
protocol->store_string_or_null(thd_info->db, system_charset_info);
2951-
if (thd_info->proc_info)
2952-
protocol->store(thd_info->proc_info, strlen(thd_info->proc_info),
2953-
system_charset_info);
2955+
if ((str= thd_info->proc_info))
2956+
protocol->store(str, strlen(str), system_charset_info);
29542957
else
29552958
protocol->store(&command_name[thd_info->command], system_charset_info);
2956-
if (thd_info->start_time && now > thd_info->start_time)
2957-
protocol->store_long((now - thd_info->start_time) / HRTIME_RESOLUTION);
2959+
if ((start_time= thd_info->start_time) && now > start_time)
2960+
protocol->store_long((now - start_time) / HRTIME_RESOLUTION);
29582961
else
29592962
protocol->store_null();
29602963
protocol->store_string_or_null(thd_info->state_info, system_charset_info);
2961-
if (thd_info->query_string.length())
2962-
protocol->store(thd_info->query_string.str(),
2963-
thd_info->query_string.length(),
2964-
thd_info->query_string.charset());
2964+
query= thd_info->query_string;
2965+
if (query.length() && query.str())
2966+
protocol->store(query.str(), query.length(), query.charset());
29652967
else
29662968
protocol->store_null();
29672969
if (!(thd->variables.old_behavior & OLD_MODE_NO_PROGRESS_INFO))

0 commit comments

Comments
 (0)