summaryrefslogtreecommitdiff
path: root/sql/field_conv.cc
diff options
context:
space:
mode:
authorGuilhem Bichot <guilhem@mysql.com>2010-11-22 09:57:59 +0100
committerGuilhem Bichot <guilhem@mysql.com>2010-11-22 09:57:59 +0100
commit96b0404940f7b704c4f8dd599455d4d2f013a297 (patch)
tree65c9141fa692262975bd2d03b092a1d54a142d97 /sql/field_conv.cc
parenta6294cd5cbd02c48b28fe8b380f8c259f14f9d8c (diff)
downloadmariadb-git-96b0404940f7b704c4f8dd599455d4d2f013a297.tar.gz
Fix for Bug#56138 "valgrind errors about overlapping memory when double-assigning same variable",
and related small fixes. mysql-test/t/user_var.test: test for bug sql/field_conv.cc: From the C standard, memcpy() has undefined behaviour if to->ptr==from->ptr sql/item_func.cc: In the case of BUG#56138, entry->value==ptr in which case memcpy() has undefined results per the C standard. sql/sql_select.cc: Work around a bug in old gcc
Diffstat (limited to 'sql/field_conv.cc')
-rw-r--r--sql/field_conv.cc7
1 files changed, 2 insertions, 5 deletions
diff --git a/sql/field_conv.cc b/sql/field_conv.cc
index 0bffde9671a..a4fca6f8ad7 100644
--- a/sql/field_conv.cc
+++ b/sql/field_conv.cc
@@ -786,11 +786,8 @@ int field_conv(Field *to,Field *from)
((Field_varstring*)from)->length_bytes ==
((Field_varstring*)to)->length_bytes))
{ // Identical fields
-#ifdef HAVE_purify
- /* This may happen if one does 'UPDATE ... SET x=x' */
- if (to->ptr != from->ptr)
-#endif
- memcpy(to->ptr,from->ptr,to->pack_length());
+ // to->ptr==from->ptr may happen if one does 'UPDATE ... SET x=x'
+ memmove(to->ptr, from->ptr, to->pack_length());
return 0;
}
}