summaryrefslogtreecommitdiff
path: root/sql/spatial.h
diff options
context:
space:
mode:
authorGeorgi Kodinov <georgi.kodinov@oracle.com>2013-03-27 16:06:33 +0200
committerGeorgi Kodinov <georgi.kodinov@oracle.com>2013-03-27 16:06:33 +0200
commit3c358724d64e7edd1fc30524eee22d272f4832ef (patch)
treea1b4fdf9d988d6240c304f73adae2f3c1ad1ace3 /sql/spatial.h
parentaccc5d92747edd889a444a9aaf64b80b55dac84f (diff)
parent0f31bfeaab33141ec001c9c69118ff1a9b337c1a (diff)
downloadmariadb-git-3c358724d64e7edd1fc30524eee22d272f4832ef.tar.gz
merge 5.1->5.5
Diffstat (limited to 'sql/spatial.h')
-rw-r--r--sql/spatial.h29
1 files changed, 26 insertions, 3 deletions
diff --git a/sql/spatial.h b/sql/spatial.h
index 1e2decd6ef3..557bf6f4a5c 100644
--- a/sql/spatial.h
+++ b/sql/spatial.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -25,7 +25,7 @@ class Gis_read_stream;
const uint SRID_SIZE= 4;
const uint SIZEOF_STORED_DOUBLE= 8;
-const uint POINT_DATA_SIZE= SIZEOF_STORED_DOUBLE*2;
+const uint POINT_DATA_SIZE= (SIZEOF_STORED_DOUBLE * 2);
const uint WKB_HEADER_SIZE= 1+4;
const uint32 GET_SIZE_ERROR= ((uint32) -1);
@@ -321,10 +321,33 @@ protected:
const char *get_mbr_for_points(MBR *mbr, const char *data, uint offset)
const;
- inline bool no_data(const char *cur_data, uint32 data_amount) const
+ /**
+ Check if there're enough data remaining as requested
+
+ @arg cur_data pointer to the position in the binary form
+ @arg data_amount number of points expected
+ @return true if not enough data
+ */
+ inline bool no_data(const char *cur_data, size_t data_amount) const
{
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
+ @return true if there are not enough points
+ */
+ inline bool not_enough_points(const char *data, uint32 expected_points) const
+ {
+ return (m_data_end < data ||
+ (expected_points > ((m_data_end - data) / POINT_DATA_SIZE)));
+ }
const char *m_data;
const char *m_data_end;
};