diff options
author | Monty <monty@mariadb.org> | 2018-05-24 19:09:33 +0300 |
---|---|---|
committer | Monty <monty@mariadb.org> | 2018-05-26 12:49:25 +0300 |
commit | 199517f501b5d50daf85d3d5620cb391c03fddfe (patch) | |
tree | 8fae790fa27f3d8093eab72926a476635aa56832 /sql/sql_string.cc | |
parent | 5a16fe0e6f33f1b123bbe9422126dd3b0fdf5ed1 (diff) | |
download | mariadb-git-199517f501b5d50daf85d3d5620cb391c03fddfe.tar.gz |
Avoid warnings in String::copy when copying string on itself (ok to do)
Diffstat (limited to 'sql/sql_string.cc')
-rw-r--r-- | sql/sql_string.cc | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/sql/sql_string.cc b/sql/sql_string.cc index 20772adcb22..2c5be35e887 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -183,7 +183,16 @@ bool String::copy(const char *str,uint32 arg_length, CHARSET_INFO *cs) { if (alloc(arg_length)) return TRUE; - if ((str_length=arg_length)) + if (Ptr == str && arg_length == str_length) + { + /* + This can happen in some cases. This code is here mainly to avoid + warnings from valgrind, but can also be an indication of error. + */ + DBUG_PRINT("warning", ("Copying string on itself: %p %lu", + str, arg_length)); + } + else if ((str_length=arg_length)) memcpy(Ptr,str,arg_length); Ptr[arg_length]=0; str_charset=cs; |