[Commits] Rev 3798: MDEV-6883 ST_WITHIN crashes server if (0, 0) is matched to POLYGON((0 0)). in file:///home/hf/wmar/mdev-6883/

holyfoot at askmonty.org holyfoot at askmonty.org
Sat Nov 15 21:48:02 EET 2014


At file:///home/hf/wmar/mdev-6883/

------------------------------------------------------------
revno: 3798
revision-id: holyfoot at askmonty.org-20141115173016-qgxw0z1cpmbul1u0
parent: psergey at askmonty.org-20141113111241-s8q6vx148yvnt7m7
committer: Alexey Botchkov <holyfoot at askmonty.org>
branch nick: mdev-6883
timestamp: Sat 2014-11-15 21:30:16 +0400
message:
  MDEV-6883 ST_WITHIN crashes server if (0,0) is matched to POLYGON((0 0)).
    Fixed the case when a polygon contains a single-point ring.
-------------- next part --------------
=== modified file 'mysql-test/r/gis.result'
--- a/mysql-test/r/gis.result	2013-03-26 18:09:47 +0000
+++ b/mysql-test/r/gis.result	2014-11-15 17:30:16 +0000
@@ -1540,3 +1540,9 @@ NULL
 Warning 1300    Invalid utf8 character string: 'E043'
 Warning 1300    Invalid utf8 character string: 'E043'
 drop table t1;
+#
+# MDEV-6883 ST_WITHIN crashes server if (0,0) is matched to POLYGON((0 0))
+#
+select st_within(GeomFromText('Polygon((0 0))'), Point(0,0));
+st_within(GeomFromText('Polygon((0 0))'), Point(0,0))
+1

=== modified file 'mysql-test/t/gis.test'
--- a/mysql-test/t/gis.test	2013-03-26 18:09:47 +0000
+++ b/mysql-test/t/gis.test	2014-11-15 17:30:16 +0000
@@ -1398,3 +1398,9 @@ insert into t1 values(geomfromtext("POIN
 insert into t1 values(geomfromtext("POINT(0 9.2233720368548e18)"));
 select equals(`a`,convert(`a` using utf8)) from `t1`;
 drop table t1;
+
+
+--echo #
+--echo # MDEV-6883 ST_WITHIN crashes server if (0,0) is matched to POLYGON((0 0))
+--echo #
+select st_within(GeomFromText('Polygon((0 0))'), Point(0,0));

=== modified file 'sql/spatial.cc'
--- a/sql/spatial.cc	2014-03-16 20:03:01 +0000
+++ b/sql/spatial.cc	2014-11-15 17:30:16 +0000
@@ -1233,11 +1233,15 @@ int Gis_polygon::store_shapes(Gcalc_shap
     trn->start_ring();
     get_point(&first_x, &first_y, data);
     data+= POINT_DATA_SIZE;
-    n_points--;
+
     prev_x= first_x;
     prev_y= first_y;
     if (trn->add_point(first_x, first_y))
       return 1;
+
+    if (--n_points == 0)
+      goto single_point_ring;
+
     while (--n_points)
     {
       double x, y;
@@ -1262,6 +1266,8 @@ int Gis_polygon::store_shapes(Gcalc_shap
         return 1;
     }
     data+= POINT_DATA_SIZE;
+
+single_point_ring:
     trn->complete_ring();
   }
 



More information about the commits mailing list