From d1bb7f9143ceafe9cbdc1e53c4ffd4abe232cb97 Mon Sep 17 00:00:00 2001 From: Monty Date: Wed, 24 Jun 2020 12:51:55 +0300 Subject: Fixed memory leak in item_sum.cc::report_cut_value_error() Only affects DBUG builds --- sql/item_sum.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sql/item_sum.cc b/sql/item_sum.cc index e79344507b2..5573cc132f0 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -3737,13 +3737,16 @@ static void report_cut_value_error(THD *thd, uint row_count, const char *fname) { size_t fn_len= strlen(fname); char *fname_upper= (char *) my_alloca(fn_len + 1); - fname_upper[fn_len]= 0; - for (; fn_len; fn_len--) - fname_upper[fn_len-1]= my_toupper(&my_charset_latin1, fname[fn_len-1]); + if (!fname_upper) + fname_upper= (char*) fname; // Out of memory + else + memcpy(fname_upper, fname, fn_len+1); + my_caseup_str(&my_charset_latin1, fname_upper); push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, ER_CUT_VALUE_GROUP_CONCAT, ER_THD(thd, ER_CUT_VALUE_GROUP_CONCAT), row_count, fname_upper); + my_afree(fname_upper); } -- cgit v1.2.1