diff --git a/mysql-test/main/t.result b/mysql-test/main/t.result new file mode 100644 index 0000000000000..38d3dd7d54083 --- /dev/null +++ b/mysql-test/main/t.result @@ -0,0 +1,7 @@ +# +# MDEV-35717: UBSAN: runtime errors: applying zero offset to null pointer in `my_strnncoll_utf8mb3_general1400_as_ci`, and applying non-zero offset 4 to null pointer in `my_strcoll_ascii_4bytes_found` +# +CREATE TABLE t (c INT,c2 CHAR,c3 DATE,CHECK (c>0)); +ALTER TABLE t ADD INDEX (c2) USING HASH; +DROP TABLE t; +# End of 11.8 tests diff --git a/mysql-test/main/t.test b/mysql-test/main/t.test new file mode 100644 index 0000000000000..f8ded30c83a92 --- /dev/null +++ b/mysql-test/main/t.test @@ -0,0 +1,10 @@ +--echo # +--echo # MDEV-35717: UBSAN: runtime errors: applying zero offset to null pointer in `my_strnncoll_utf8mb3_general1400_as_ci`, and applying non-zero offset 4 to null pointer in `my_strcoll_ascii_4bytes_found` +--echo # + +CREATE TABLE t (c INT,c2 CHAR,c3 DATE,CHECK (c>0)); +ALTER TABLE t ADD INDEX (c2) USING HASH; + +DROP TABLE t; + +--echo # End of 11.8 tests diff --git a/strings/strcoll.inl b/strings/strcoll.inl index 567d827d5f46e..ff0108b94eb0c 100644 --- a/strings/strcoll.inl +++ b/strings/strcoll.inl @@ -226,8 +226,8 @@ MY_FUNCTION_NAME(strnncoll)(CHARSET_INFO *cs __attribute__((unused)), const uchar *b, size_t b_length, my_bool b_is_prefix) { - const uchar *a_end= a + a_length; - const uchar *b_end= b + b_length; + const uchar *a_end= a ? a + a_length : NULL; + const uchar *b_end= b ? b + b_length : NULL; for ( ; ; ) { int a_weight, b_weight, res;