diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result
index 643a3d6b43478fc3d29679f7f0a9497cad7e6bed..55f70e59fcf625b4d3983d51c02387d2d348ae6c 100644
--- a/mysql-test/r/gis.result
+++ b/mysql-test/r/gis.result
@@ -724,4 +724,10 @@ SELECT * FROM t1;
 a
 NULL
 DROP TABLE t1;
+CREATE TABLE `t1` ( `col9` set('a'), `col89` date);
+INSERT INTO `t1` VALUES ('','0000-00-00');
+select geomfromtext(col9,col89) as a from t1;
+a
+NULL
+DROP TABLE t1;
 End of 4.1 tests
diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test
index 7182e040d468af36cd70c1bf2906edbfb7225094..cf5c3b31bc1a631527a004ba7eff3490952462c6 100644
--- a/mysql-test/t/gis.test
+++ b/mysql-test/t/gis.test
@@ -419,4 +419,12 @@ INSERT INTO t1 VALUES (NULL);
 SELECT * FROM t1;
 DROP TABLE t1;
 
+#
+# Bug #30955 geomfromtext() crasher
+#
+CREATE TABLE `t1` ( `col9` set('a'), `col89` date);
+INSERT INTO `t1` VALUES ('','0000-00-00');
+select geomfromtext(col9,col89) as a from t1;
+DROP TABLE t1;
+
 --echo End of 4.1 tests
diff --git a/sql/gstream.cc b/sql/gstream.cc
index f7d11d76b0c4ae1d139eb456f219b9e22a392809..f986d9dc7f369b91ad72770716342754b77f2196 100644
--- a/sql/gstream.cc
+++ b/sql/gstream.cc
@@ -45,7 +45,7 @@ bool Gis_read_stream::get_next_word(LEX_STRING *res)
   skip_space();
   res->str= (char*) m_cur;
   /* The following will also test for \0 */
-  if (!my_isvar_start(&my_charset_bin, *m_cur))
+  if ((m_cur >= m_limit) || !my_isvar_start(&my_charset_bin, *m_cur))
     return 1;
 
   /*