summaryrefslogtreecommitdiff
path: root/client/sql_string.h
diff options
context:
space:
mode:
authorunknown <cmiller@zippy.(none)>2006-07-01 14:31:52 -0400
committerunknown <cmiller@zippy.(none)>2006-07-01 14:31:52 -0400
commit861096a58f9c3f246d8a7b448601a422c8e04f26 (patch)
tree4994852e905e2fb263529a96c775e23669a2a296 /client/sql_string.h
parentc90f464d8fc051a338b0b99849befd919e4e3431 (diff)
downloadmariadb-git-861096a58f9c3f246d8a7b448601a422c8e04f26.tar.gz
Bug#19006: 4.0 valgrind problems (in test func_str)
On exactly-sized Strings, the String::c_ptr() function peeked beyond the end of the buffer, possibly into unititialized space to see whether the buffer was NUL-terminated. In a place that did peek improperly, we now use a c_ptr_safe() function, which doesn't peek where it shouldn't. client/sql_string.h: Back-port String::c_ptr_safe(). sql/item_func.h: Describe side-effect behavior. sql/item_strfunc.cc: Use the "_safe" version of c_ptr to avoid looking for a terminating NUL character outside the initialized memory area. Valgrind hates it when one does that, and it theoretically could lead to a SEGV. sql/sql_string.h: Back-port String::c_ptr_safe().
Diffstat (limited to 'client/sql_string.h')
-rw-r--r--client/sql_string.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/client/sql_string.h b/client/sql_string.h
index cffe78936a0..13687eef4dc 100644
--- a/client/sql_string.h
+++ b/client/sql_string.h
@@ -67,6 +67,14 @@ public:
Ptr[str_length]=0;
return Ptr;
}
+ inline char *c_ptr_safe()
+ {
+ if (Ptr && str_length < Alloced_length)
+ Ptr[str_length]=0;
+ else
+ (void) realloc(str_length);
+ return Ptr;
+ }
void set(String &str,uint32 offset,uint32 arg_length)
{