Avoid warnings in String::copy when copying string on itself (ok to do)
This commit is contained in:
parent
5a16fe0e6f
commit
199517f501
@ -183,7 +183,16 @@ bool String::copy(const char *str,uint32 arg_length, CHARSET_INFO *cs)
|
|||||||
{
|
{
|
||||||
if (alloc(arg_length))
|
if (alloc(arg_length))
|
||||||
return TRUE;
|
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);
|
memcpy(Ptr,str,arg_length);
|
||||||
Ptr[arg_length]=0;
|
Ptr[arg_length]=0;
|
||||||
str_charset=cs;
|
str_charset=cs;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user