diff options
author | Igor Babaev <igor@askmonty.org> | 2013-08-15 14:04:20 -0700 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2013-08-15 14:04:20 -0700 |
commit | 960720b10dc463a73214786302f009356c2284ce (patch) | |
tree | e9c7748d0625f14a4c3a2a1d328b2ff0cace1990 /sql/spatial.h | |
parent | f1b4718ec894664df221704bb70fed80bdc14070 (diff) | |
parent | 7ba78277b4d76649501e85f05be2780e00ffc9c3 (diff) | |
download | mariadb-git-960720b10dc463a73214786302f009356c2284ce.tar.gz |
Merge 5.2->5.3
Diffstat (limited to 'sql/spatial.h')
-rw-r--r-- | sql/spatial.h | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/sql/spatial.h b/sql/spatial.h index aa7e8fd0c8d..b9b9bddf5f9 100644 --- a/sql/spatial.h +++ b/sql/spatial.h @@ -212,11 +212,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) @@ -337,6 +332,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; }; |