summaryrefslogtreecommitdiff
path: root/sql/sql_string.cc
diff options
context:
space:
mode:
authorAlexey Kopytov <Alexey.Kopytov@sun.com>2009-02-13 19:20:56 +0300
committerAlexey Kopytov <Alexey.Kopytov@sun.com>2009-02-13 19:20:56 +0300
commit7cc2e62e25bec1a028353f1e0f9a2e401bd9b7f4 (patch)
treee907d3bf6c88897a516896d7cc9dac08985f5907 /sql/sql_string.cc
parent060c89940ff0cb9a92f40cbcd95d7dae0add4e97 (diff)
parentccd5a4dc462e7a7dd8ebb39016b033636b0db92d (diff)
downloadmariadb-git-7cc2e62e25bec1a028353f1e0f9a2e401bd9b7f4.tar.gz
Merge mysql-5.0-bugteam -> mysql-5.1-bugteam.
Diffstat (limited to 'sql/sql_string.cc')
-rw-r--r--sql/sql_string.cc15
1 files changed, 6 insertions, 9 deletions
diff --git a/sql/sql_string.cc b/sql/sql_string.cc
index 34b310931d6..3098e8ed044 100644
--- a/sql/sql_string.cc
+++ b/sql/sql_string.cc
@@ -71,25 +71,22 @@ bool String::realloc(uint32 alloc_length)
char *new_ptr;
if (alloced)
{
- if ((new_ptr= (char*) my_realloc(Ptr,len,MYF(MY_WME))))
- {
- Ptr=new_ptr;
- Alloced_length=len;
- }
- else
- return TRUE; // Signal error
+ if (!(new_ptr= (char*) my_realloc(Ptr,len,MYF(MY_WME))))
+ return TRUE; // Signal error
}
else if ((new_ptr= (char*) my_malloc(len,MYF(MY_WME))))
{
+ if (str_length > len - 1)
+ str_length= 0;
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;
alloced=1;
}
else
return TRUE; // Signal error
+ Ptr= new_ptr;
+ Alloced_length= len;
}
Ptr[alloc_length]=0; // This make other funcs shorter
return FALSE;