summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/func_str.result12
-rw-r--r--mysql-test/t/func_str.test16
-rw-r--r--sql/item_strfunc.cc2
3 files changed, 30 insertions, 0 deletions
diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result
index 798b4f9ff09..f9346a25151 100644
--- a/mysql-test/r/func_str.result
+++ b/mysql-test/r/func_str.result
@@ -4835,3 +4835,15 @@ DROP TABLE t1;
#
# End of 10.1 tests
#
+#
+# Start of 10.2 tests
+#
+#
+# MDEV-24742 Server crashes in Charset::numchars / String::numchars
+#
+SELECT NULL IN (RIGHT(AES_ENCRYPT('foo','bar'), LAST_INSERT_ID()), 'qux');
+NULL IN (RIGHT(AES_ENCRYPT('foo','bar'), LAST_INSERT_ID()), 'qux')
+NULL
+#
+# End of 10.2 tests
+#
diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test
index 1a59946e97e..366aacb1945 100644
--- a/mysql-test/t/func_str.test
+++ b/mysql-test/t/func_str.test
@@ -1932,3 +1932,19 @@ DROP TABLE t1;
--echo #
--echo # End of 10.1 tests
--echo #
+
+
+--echo #
+--echo # Start of 10.2 tests
+--echo #
+
+--echo #
+--echo # MDEV-24742 Server crashes in Charset::numchars / String::numchars
+--echo #
+
+SELECT NULL IN (RIGHT(AES_ENCRYPT('foo','bar'), LAST_INSERT_ID()), 'qux');
+
+
+--echo #
+--echo # End of 10.2 tests
+--echo #
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 26a23b0cb55..e5935178f10 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -338,6 +338,8 @@ String *Item_aes_crypt::val_str(String *str2)
rkey, AES_KEY_LENGTH / 8, 0, 0))
{
str2->length((uint) aes_length);
+ DBUG_ASSERT(collation.collation == &my_charset_bin);
+ str2->set_charset(&my_charset_bin);
return str2;
}
}