Skip to content

Commit

Permalink
Avoid warnings in String::copy when copying string on itself (ok to do)
Browse files Browse the repository at this point in the history
  • Loading branch information
montywi committed May 26, 2018
1 parent 5a16fe0 commit 199517f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion sql/sql_string.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 199517f

Please sign in to comment.