Skip to content

Commit f0590e6

Browse files
Bug#10063897 - COM_EXECUTE potential problem.
The patch ensures that final character set and the placeholder character set are not NULL in the function Item_param::convert_str_value. Reviewed-By: Alexander Nozdrin, Dmitry Shulga.
1 parent 2853558 commit f0590e6

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

sql/item.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3968,6 +3968,9 @@ bool Item_param::convert_str_value(THD *thd)
39683968
bool rc= FALSE;
39693969
if (state == STRING_VALUE || state == LONG_DATA_VALUE)
39703970
{
3971+
if (value.cs_info.final_character_set_of_str_value == NULL ||
3972+
value.cs_info.character_set_of_placeholder == NULL)
3973+
return true;
39713974
/*
39723975
Check is so simple because all charsets were set up properly
39733976
in setup_one_conversion_function, where typecode of

unittest/gunit/item_param-t.cc

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
2+
3+
This program is free software; you can redistribute it and/or modify
4+
it under the terms of the GNU General Public License as published by
5+
the Free Software Foundation; version 2 of the License.
6+
7+
This program is distributed in the hope that it will be useful,
8+
but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
GNU General Public License for more details.
11+
12+
You should have received a copy of the GNU General Public License
13+
along with this program; if not, write to the Free Software
14+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15+
16+
#include "my_config.h"
17+
#include <gtest/gtest.h>
18+
#include <item.h>
19+
20+
#include "test_utils.h"
21+
22+
namespace item_param_unittest {
23+
using my_testing::Server_initializer;
24+
25+
class ItemParamTest : public ::testing::Test
26+
{
27+
protected:
28+
virtual void SetUp()
29+
{
30+
m_initializer.SetUp();
31+
// An Item expects to be owned by current_thd->free_list, so allocate with
32+
// new, and do not delete it.
33+
m_item_param= new Item_param(POS(), 1);
34+
}
35+
36+
virtual void TearDown()
37+
{
38+
m_initializer.TearDown();
39+
}
40+
41+
Server_initializer m_initializer;
42+
Item_param *m_item_param;
43+
};
44+
45+
TEST_F(ItemParamTest, convert_str_value)
46+
{
47+
m_item_param->state= Item_param::LONG_DATA_VALUE;
48+
m_item_param->value.cs_info.final_character_set_of_str_value= NULL;
49+
EXPECT_TRUE(m_item_param->convert_str_value(m_initializer.thd()));
50+
}
51+
}

0 commit comments

Comments
 (0)