summaryrefslogtreecommitdiff
path: root/sql/sql_string.cc
diff options
context:
space:
mode:
authorIgnacio Galarza <iggy@mysql.com>2009-03-17 16:29:24 -0400
committerIgnacio Galarza <iggy@mysql.com>2009-03-17 16:29:24 -0400
commit0d588edf61c93ab67fb7e26101a0fc00d021bb11 (patch)
tree3c313f70fd16653491985d8e8108fb5b99f0d5d0 /sql/sql_string.cc
parent5b7347bda31b9d66cd78937e5dc339f553b9a736 (diff)
parent7ca1ebd83a1a7d291593be7a94f5a37298dfc863 (diff)
downloadmariadb-git-0d588edf61c93ab67fb7e26101a0fc00d021bb11.tar.gz
auto-merge
Diffstat (limited to 'sql/sql_string.cc')
-rw-r--r--sql/sql_string.cc19
1 files changed, 8 insertions, 11 deletions
diff --git a/sql/sql_string.cc b/sql/sql_string.cc
index 9024f98bd92..1dd7b55d136 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;
@@ -115,7 +112,7 @@ bool String::set_real(double num,uint decimals, CHARSET_INFO *cs)
str_charset=cs;
if (decimals >= NOT_FIXED_DEC)
{
- uint32 len= my_sprintf(buff,(buff, "%.14g",num));// Enough for a DATETIME
+ uint32 len= my_sprintf(buff,(buff, "%.15g",num));// Enough for a DATETIME
return copy(buff, len, &my_charset_latin1, cs, &dummy_errors);
}
#ifdef HAVE_FCONVERT
@@ -667,7 +664,7 @@ void String::qs_append(const char *str, uint32 len)
void String::qs_append(double d)
{
char *buff = Ptr + str_length;
- str_length+= my_sprintf(buff, (buff, "%.14g", d));
+ str_length+= my_sprintf(buff, (buff, "%.15g", d));
}
void String::qs_append(double *d)