From 3d8c447b3a4a84b6eeed932015f0e7f5b9152adf Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Fri, 27 Apr 2018 14:17:01 +0300 Subject: [PATCH] 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. --- server/core/poll.cc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/server/core/poll.cc b/server/core/poll.cc index b40cae50a..bbdc3d310 100644 --- a/server/core/poll.cc +++ b/server/core/poll.cc @@ -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) {