summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2021-02-18 12:16:11 +0100
committerSergei Golubchik <serg@mariadb.org>2021-02-18 12:16:11 +0100
commitcbbbdb9c3bfbda7c2e7336cd68554f81714d3d97 (patch)
tree054f2839ced1b117aca5717274e3022aaf23b143 /sql
parente7d9c1d498d0b86ef773f21a95f60af26b2dce75 (diff)
downloadmariadb-git-cbbbdb9c3bfbda7c2e7336cd68554f81714d3d97.tar.gz
don't allocate 64K on the stack
Diffstat (limited to 'sql')
-rw-r--r--sql/wsrep_notify.cc10
1 files changed, 7 insertions, 3 deletions
diff --git a/sql/wsrep_notify.cc b/sql/wsrep_notify.cc
index fb04d7be7c1..3683d70a980 100644
--- a/sql/wsrep_notify.cc
+++ b/sql/wsrep_notify.cc
@@ -40,11 +40,13 @@ void wsrep_notify_status (wsrep_member_status_t status,
return;
}
- char cmd_buf[1 << 16]; // this can be long
- long cmd_len = sizeof(cmd_buf) - 1;
- char* cmd_ptr = cmd_buf;
+ const long cmd_len = (1 << 16) - 1;
+ char* cmd_ptr = (char*) my_malloc(cmd_len + 1, MYF(MY_WME));
long cmd_off = 0;
+ if (!cmd_ptr)
+ return; // the warning is in the log
+
cmd_off += snprintf (cmd_ptr + cmd_off, cmd_len - cmd_off, "%s",
wsrep_notify_cmd);
@@ -93,6 +95,7 @@ void wsrep_notify_status (wsrep_member_status_t status,
{
WSREP_ERROR("Notification buffer too short (%ld). Aborting notification.",
cmd_len);
+ my_free(cmd_ptr);
return;
}
@@ -106,5 +109,6 @@ void wsrep_notify_status (wsrep_member_status_t status,
WSREP_ERROR("Notification command failed: %d (%s): \"%s\"",
err, strerror(err), cmd_ptr);
}
+ my_free(cmd_ptr);
}