summaryrefslogtreecommitdiff
path: root/sql/sql_string.h
diff options
context:
space:
mode:
authorsergefp@mysql.com <>2005-02-04 09:14:22 +0300
committersergefp@mysql.com <>2005-02-04 09:14:22 +0300
commit38339e1c516f2c7d466c440f88013e5c92c40445 (patch)
treedf20fcb468895423bb135dd8c9ec93140e32963b /sql/sql_string.h
parente87bd60c12452e5cac8cc72708de8ed222bbd066 (diff)
downloadmariadb-git-38339e1c516f2c7d466c440f88013e5c92c40445.tar.gz
Fix for BUG#7716: in in_string::set() take into account that the value returned
by item->val_str() may be a substring of the passed string. Disallow string=its_substring assignment in String::operator=().
Diffstat (limited to 'sql/sql_string.h')
-rw-r--r--sql/sql_string.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/sql/sql_string.h b/sql/sql_string.h
index a8fb9574c0b..9136dddbbf2 100644
--- a/sql/sql_string.h
+++ b/sql/sql_string.h
@@ -182,6 +182,11 @@ public:
{
if (&s != this)
{
+ /*
+ It is forbidden to do assignments like
+ some_string = substring_of_that_string
+ */
+ DBUG_ASSERT(!s.uses_buffer_owned_by(this));
free();
Ptr=s.Ptr ; str_length=s.str_length ; Alloced_length=s.Alloced_length;
alloced=0;
@@ -313,4 +318,9 @@ public:
/* Swap two string objects. Efficient way to exchange data without memcpy. */
void swap(String &s);
+
+ inline bool uses_buffer_owned_by(const String *s) const
+ {
+ return (s->alloced && Ptr >= s->Ptr && Ptr < s->Ptr + s->str_length);
+ }
};