mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
Fix UBSan report in pointInPolygon
This commit is contained in:
parent
7c17e2526d
commit
9290d6f112
@ -6,6 +6,7 @@
|
||||
#include <Columns/IColumn.h>
|
||||
#include <Columns/ColumnVector.h>
|
||||
#include <Common/typeid_cast.h>
|
||||
#include <Common/NaNUtils.h>
|
||||
#include <Common/SipHash.h>
|
||||
#include <common/range.h>
|
||||
|
||||
@ -304,6 +305,13 @@ void PointInPolygonWithGrid<CoordinateType>::calcGridAttributes(
|
||||
y_scale = 1 / cell_height;
|
||||
x_shift = -min_corner.x();
|
||||
y_shift = -min_corner.y();
|
||||
|
||||
if (!(isFinite(x_scale)
|
||||
&& isFinite(y_scale)
|
||||
&& isFinite(x_shift)
|
||||
&& isFinite(y_shift)
|
||||
&& isFinite(grid_size)))
|
||||
throw Exception("Polygon is not valid: bounding box is unbounded", ErrorCodes::BAD_ARGUMENTS);
|
||||
}
|
||||
|
||||
template <typename CoordinateType>
|
||||
@ -358,7 +366,7 @@ bool PointInPolygonWithGrid<CoordinateType>::contains(CoordinateType x, Coordina
|
||||
if (has_empty_bound)
|
||||
return false;
|
||||
|
||||
if (std::isnan(x) || std::isnan(y))
|
||||
if (!isFinite(x) || !isFinite(y))
|
||||
return false;
|
||||
|
||||
CoordinateType float_row = (y + y_shift) * y_scale;
|
||||
|
@ -0,0 +1 @@
|
||||
0
|
@ -0,0 +1,2 @@
|
||||
SET validate_polygons = 0;
|
||||
SELECT pointInPolygon((-inf, 1023), [(10.000100135803223, 10000000000.), (inf, 0.9998999834060669), (1.1920928955078125e-7, 100.0000991821289), (1.000100016593933, 100.0000991821289)]);
|
Loading…
Reference in New Issue
Block a user