summaryrefslogtreecommitdiff
path: root/sql/spatial.h
diff options
context:
space:
mode:
authorAlexey Botchkov <holyfoot@askmonty.org>2013-07-22 00:55:06 +0500
committerAlexey Botchkov <holyfoot@askmonty.org>2013-07-22 00:55:06 +0500
commit9b67de47972d2d7a40f2fe7a8898e3cbef9886a7 (patch)
treee04260573342cc913f9222496fe2219df2a8daa9 /sql/spatial.h
parent48b403cd65a680c5ea526225cad82a44779d0178 (diff)
downloadmariadb-git-9b67de47972d2d7a40f2fe7a8898e3cbef9886a7.tar.gz
MDEV-4478 check mysql-5.5 changes in spatial.cc.
not_enough_points() introduced to check if the spatial object is incorrect.
Diffstat (limited to 'sql/spatial.h')
-rw-r--r--sql/spatial.h24
1 files changed, 19 insertions, 5 deletions
diff --git a/sql/spatial.h b/sql/spatial.h
index d7632c11143..0b1b8afd35c 100644
--- a/sql/spatial.h
+++ b/sql/spatial.h
@@ -197,11 +197,6 @@ struct Geometry_buffer;
class Geometry
{
public:
- // Maximum number of points in feature that can fit into String
- static const uint32 max_n_points=
- (uint32) (INT_MAX32 - WKB_HEADER_SIZE - 4 /* n_points */) /
- POINT_DATA_SIZE;
-public:
Geometry() {} /* Remove gcc warning */
virtual ~Geometry() {} /* Remove gcc warning */
static void *operator new(size_t size, void *buffer)
@@ -326,6 +321,25 @@ protected:
{
return (cur_data + data_amount > m_data_end);
}
+
+ /**
+ Check if there're enough points remaining as requested
+
+ Need to perform the calculation in logical units, since multiplication
+ can overflow the size data type.
+
+ @arg data pointer to the begining of the points array
+ @arg expected_points number of points expected
+ @arg extra_point_space extra space for each point element in the array
+ @return true if there are not enough points
+ */
+ inline bool not_enough_points(const char *data, uint32 expected_points,
+ uint32 extra_point_space = 0) const
+ {
+ return (m_data_end < data ||
+ (expected_points > ((m_data_end - data) /
+ (POINT_DATA_SIZE + extra_point_space))));
+ }
const char *m_data;
const char *m_data_end;
};