diff --git a/mysql-test/main/xml.result b/mysql-test/main/xml.result
index d0b1d1782a1..a960d8cc316 100644
--- a/mysql-test/main/xml.result
+++ b/mysql-test/main/xml.result
@@ -1320,5 +1320,17 @@ f
foo
#
-# Start of 10.5 tests
+# End of 10.5 tests
#
+# Start of 11.4 tests
+#
+# MDEV-36565 Assertion `src != ((void *)0)' failed in my_casedn_8bit
+#
+SET NAMES latin1;
+SELECT lcase((extractvalue('a', 'a'))) a FROM (select 1) dt;
+a
+
+SELECT ucase((extractvalue('a', 'a'))) a FROM (select 1) dt;
+a
+
+# End of 11.4 tests
diff --git a/mysql-test/main/xml.test b/mysql-test/main/xml.test
index 2d0dd9907bb..e0954c5f6bb 100644
--- a/mysql-test/main/xml.test
+++ b/mysql-test/main/xml.test
@@ -822,5 +822,17 @@ DROP TABLE t1;
SELECT 'foo' AS f UNION SELECT BINARY( UpdateXML('', '/a', '')) AS f;
--echo #
---echo # Start of 10.5 tests
+--echo # End of 10.5 tests
--echo #
+
+--echo # Start of 11.4 tests
+
+--echo #
+--echo # MDEV-36565 Assertion `src != ((void *)0)' failed in my_casedn_8bit
+--echo #
+
+SET NAMES latin1;
+SELECT lcase((extractvalue('a', 'a'))) a FROM (select 1) dt;
+SELECT ucase((extractvalue('a', 'a'))) a FROM (select 1) dt;
+
+--echo # End of 11.4 tests
diff --git a/sql/item_xmlfunc.cc b/sql/item_xmlfunc.cc
index 02c37b45d8f..86c4e423947 100644
--- a/sql/item_xmlfunc.cc
+++ b/sql/item_xmlfunc.cc
@@ -176,8 +176,8 @@ public:
}
}
- str->length(0);
- str->set_charset(collation.collation);
+ // Make sure we never return {Ptr=nullptr, str_length=0}
+ str->copy("", 0, collation.collation);
for (uint i=0 ; i < numnodes; i++)
{
if(active[i])