summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorunknown <monty@donna.mysql.com>2000-10-20 17:40:13 +0300
committerunknown <monty@donna.mysql.com>2000-10-20 17:40:13 +0300
commit94c93b9ec7f68ba50219818caec23e61f85b800d (patch)
treedb3cf7c252d4ecb4845267a1731209451a2a92df /client
parent23b8fccb93bd640bdd1b23af3afda15280e52485 (diff)
parent982260d2cb5ec6b3864a34a4cb355160986f807f (diff)
downloadmariadb-git-94c93b9ec7f68ba50219818caec23e61f85b800d.tar.gz
Merge work:/home/bk/mysql into donna.mysql.com:/home/my/bk/mysql
Docs/manual.texi: Auto merged
Diffstat (limited to 'client')
-rw-r--r--client/sql_string.cc31
1 files changed, 19 insertions, 12 deletions
diff --git a/client/sql_string.cc b/client/sql_string.cc
index 67ce0f6ff54..7ca2d3c419e 100644
--- a/client/sql_string.cc
+++ b/client/sql_string.cc
@@ -81,7 +81,8 @@ bool String::realloc(uint32 alloc_length)
}
else if ((new_ptr= (char*) my_malloc(len,MYF(MY_WME))))
{
- memcpy(new_ptr,Ptr,str_length);
+ if (str_length) // Avoid bugs in memcpy on AIX
+ memcpy(new_ptr,Ptr,str_length);
new_ptr[str_length]=0;
Ptr=new_ptr;
Alloced_length=len;
@@ -221,8 +222,8 @@ bool String::copy(const char *str,uint32 arg_length)
{
if (alloc(arg_length))
return TRUE;
- str_length=arg_length;
- memcpy(Ptr,str,arg_length);
+ if ((str_length=arg_length))
+ memcpy(Ptr,str,arg_length);
Ptr[arg_length]=0;
return FALSE;
}
@@ -251,17 +252,21 @@ void String::strip_sp()
bool String::append(const String &s)
{
- if (realloc(str_length+s.length()))
- return TRUE;
- memcpy(Ptr+str_length,s.ptr(),s.length());
- str_length+=s.length();
+ if (s.length())
+ {
+ if (realloc(str_length+s.length()))
+ return TRUE;
+ memcpy(Ptr+str_length,s.ptr(),s.length());
+ str_length+=s.length();
+ }
return FALSE;
}
bool String::append(const char *s,uint32 arg_length)
{
if (!arg_length) // Default argument
- arg_length= (uint32) strlen(s);
+ if (!(arg_length= (uint32) strlen(s)))
+ return FALSE;
if (realloc(str_length+arg_length))
return TRUE;
memcpy(Ptr+str_length,s,arg_length);
@@ -398,7 +403,8 @@ bool String::replace(uint32 offset,uint32 arg_length,const String &to)
{
if (diff < 0)
{
- memcpy(Ptr+offset,to.ptr(),to.length());
+ if (to.length())
+ memcpy(Ptr+offset,to.ptr(),to.length());
bmove(Ptr+offset+to.length(),Ptr+offset+arg_length,
str_length-offset-arg_length);
}
@@ -411,7 +417,8 @@ bool String::replace(uint32 offset,uint32 arg_length,const String &to)
bmove_upp(Ptr+str_length+diff,Ptr+str_length,
str_length-offset-arg_length);
}
- memcpy(Ptr+offset,to.ptr(),to.length());
+ if (to.length())
+ memcpy(Ptr+offset,to.ptr(),to.length());
}
str_length+=(uint32) diff;
}
@@ -502,8 +509,8 @@ String *copy_if_not_alloced(String *to,String *from,uint32 from_length)
}
if (to->realloc(from_length))
return from; // Actually an error
- to->str_length=min(from->str_length,from_length);
- memcpy(to->Ptr,from->Ptr,to->str_length);
+ if ((to->str_length=min(from->str_length,from_length)))
+ memcpy(to->Ptr,from->Ptr,to->str_length);
return to;
}