summaryrefslogtreecommitdiff
path: root/sql/gstream.cc
diff options
context:
space:
mode:
authorunknown <hf@deer.(none)>2004-03-15 16:32:53 +0400
committerunknown <hf@deer.(none)>2004-03-15 16:32:53 +0400
commit9a3fbf0d96426dd5273bb8992c4b131965e6d1e1 (patch)
tree2cab975faaba9bbd5292393c6b415c5159079213 /sql/gstream.cc
parent22657f672c8d4c005f85cd3efc714d98b635f3f0 (diff)
downloadmariadb-git-9a3fbf0d96426dd5273bb8992c4b131965e6d1e1.tar.gz
Fix for valgrind's warning
sql/gstream.cc: checking for ending \0 changed with m_limit sql/gstream.h: checking for ending \0 changed with m_limit sql/item_geofunc.cc: we should check for null value before we use val_str result sql/item_strfunc.cc: get rid of annoying warnings sql/spatial.h: error about size_t type fixed
Diffstat (limited to 'sql/gstream.cc')
-rw-r--r--sql/gstream.cc17
1 files changed, 11 insertions, 6 deletions
diff --git a/sql/gstream.cc b/sql/gstream.cc
index 6b1e12ec733..f7d11d76b0c 100644
--- a/sql/gstream.cc
+++ b/sql/gstream.cc
@@ -24,7 +24,7 @@
enum Gis_read_stream::enum_tok_types Gis_read_stream::get_next_toc_type()
{
skip_space();
- if (!*m_cur)
+ if (m_cur >= m_limit)
return eostream;
if (my_isvar_start(&my_charset_bin, *m_cur))
return word;
@@ -53,7 +53,7 @@ bool Gis_read_stream::get_next_word(LEX_STRING *res)
my_isvar() is a macro that would cause side effects
*/
m_cur++;
- while (my_isvar(&my_charset_bin, *m_cur))
+ while ((m_cur < m_limit) && my_isvar(&my_charset_bin, *m_cur))
m_cur++;
res->length= (uint32) (m_cur - res->str);
@@ -71,16 +71,21 @@ bool Gis_read_stream::get_next_word(LEX_STRING *res)
bool Gis_read_stream::get_next_number(double *d)
{
char *endptr;
+ int err;
skip_space();
- /* The following will also test for end \0 */
- if ((*m_cur < '0' || *m_cur > '9') && *m_cur != '-' && *m_cur != '+')
+
+ if ((m_cur >= m_limit) ||
+ (*m_cur < '0' || *m_cur > '9') && *m_cur != '-' && *m_cur != '+')
{
set_error_msg("Numeric constant expected");
return 1;
}
- *d = my_strtod(m_cur, &endptr);
+ *d = my_strntod(m_charset, (char *)m_cur,
+ m_limit-m_cur, &endptr, &err);
+ if (err)
+ return 1;
if (endptr)
m_cur = endptr;
return 0;
@@ -90,7 +95,7 @@ bool Gis_read_stream::get_next_number(double *d)
bool Gis_read_stream::check_next_symbol(char symbol)
{
skip_space();
- if (*m_cur != symbol)
+ if ((m_cur >= m_limit) || (*m_cur != symbol))
{
char buff[32];
strmov(buff, "'?' expected");