Commit c9742cea authored by Alexey Botchkov's avatar Alexey Botchkov

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.
parent 50c53392
...@@ -1540,3 +1540,9 @@ Warnings: ...@@ -1540,3 +1540,9 @@ Warnings:
Warning 1300 Invalid utf8 character string: 'E043' Warning 1300 Invalid utf8 character string: 'E043'
Warning 1300 Invalid utf8 character string: 'E043' Warning 1300 Invalid utf8 character string: 'E043'
drop table t1; 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
...@@ -1398,3 +1398,9 @@ insert into t1 values(geomfromtext("POINT(0 9.2233720368548e18)")); ...@@ -1398,3 +1398,9 @@ insert into t1 values(geomfromtext("POINT(0 9.2233720368548e18)"));
insert into t1 values(geomfromtext("POINT(0 9.2233720368548e18)")); insert into t1 values(geomfromtext("POINT(0 9.2233720368548e18)"));
select equals(`a`,convert(`a` using utf8)) from `t1`; select equals(`a`,convert(`a` using utf8)) from `t1`;
drop table 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));
...@@ -1233,11 +1233,15 @@ int Gis_polygon::store_shapes(Gcalc_shape_transporter *trn) const ...@@ -1233,11 +1233,15 @@ int Gis_polygon::store_shapes(Gcalc_shape_transporter *trn) const
trn->start_ring(); trn->start_ring();
get_point(&first_x, &first_y, data); get_point(&first_x, &first_y, data);
data+= POINT_DATA_SIZE; data+= POINT_DATA_SIZE;
n_points--;
prev_x= first_x; prev_x= first_x;
prev_y= first_y; prev_y= first_y;
if (trn->add_point(first_x, first_y)) if (trn->add_point(first_x, first_y))
return 1; return 1;
if (--n_points == 0)
goto single_point_ring;
while (--n_points) while (--n_points)
{ {
double x, y; double x, y;
...@@ -1262,6 +1266,8 @@ int Gis_polygon::store_shapes(Gcalc_shape_transporter *trn) const ...@@ -1262,6 +1266,8 @@ int Gis_polygon::store_shapes(Gcalc_shape_transporter *trn) const
return 1; return 1;
} }
data+= POINT_DATA_SIZE; data+= POINT_DATA_SIZE;
single_point_ring:
trn->complete_ring(); trn->complete_ring();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment