From fcfa5682bc1b627d96007393deb735555e05aa2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Sat, 25 Mar 2017 22:20:06 +0000 Subject: [PATCH] Fix bug #970 Crash on mysql-query_digests=false, mysql-commands_stats=true, and short query --- lib/Query_Processor.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Query_Processor.cpp b/lib/Query_Processor.cpp index 02d939d4e..b14bfa2ac 100644 --- a/lib/Query_Processor.cpp +++ b/lib/Query_Processor.cpp @@ -1024,7 +1024,11 @@ void Query_Processor::query_parser_init(SQP_par_t *qp, char *query, int query_le #endif /* DEBUG */ } else { if (mysql_thread___commands_stats) { - qp->query_prefix=strndup(query,32); + size_t sl=32; + if ((unsigned int)query_length < sl) { + sl=query_length; + } + qp->query_prefix=strndup(query,sl); } } };