MXS-1836 Do not store pointer to data on the stack

First the resultset objects is created, then then the iteration
is done. Consequently, the user data cannot refer to anything
on the stack.
This commit is contained in:
Johan Wikman 2018-04-27 14:17:01 +03:00
parent 1e700ab9ba
commit 3d8c447b3a

View File

@ -331,7 +331,7 @@ namespace
struct EVENT_TIMES_CB_DATA
{
int rowno;
Worker::STATISTICS* stats;
Worker::STATISTICS stats;
};
}
@ -374,10 +374,10 @@ eventTimesRowCallback(RESULTSET *set, void *v)
resultset_row_set(row, 0, buf);
}
snprintf(buf, 39, "%u", data->stats->qtimes[data->rowno]);
snprintf(buf, 39, "%u", data->stats.qtimes[data->rowno]);
buf[39] = '\0';
resultset_row_set(row, 1, buf);
snprintf(buf, 39, "%u", data->stats->exectimes[data->rowno]);
snprintf(buf, 39, "%u", data->stats.exectimes[data->rowno]);
buf[39] = '\0';
resultset_row_set(row, 2, buf);
data->rowno++;
@ -400,10 +400,8 @@ eventTimesGetList()
return NULL;
}
Worker::STATISTICS s = Worker::get_statistics();
data->rowno = 0;
data->stats = &s;
data->stats = Worker::get_statistics();
if ((set = resultset_create(eventTimesRowCallback, data)) == NULL)
{