Commit fd35e787 authored by unknown's avatar unknown

Fix for bug#8978 : Crash on 'select format ...'

parent 32773212
...@@ -1465,7 +1465,8 @@ Item_func_format::Item_func_format(Item *org,int dec) :Item_str_func(org) ...@@ -1465,7 +1465,8 @@ Item_func_format::Item_func_format(Item *org,int dec) :Item_str_func(org)
String *Item_func_format::val_str(String *str) String *Item_func_format::val_str(String *str)
{ {
double nr =args[0]->val(); double nr =args[0]->val();
uint32 diff,length,str_length; uint32 length,str_length;
int diff;
uint dec; uint dec;
if ((null_value=args[0]->null_value)) if ((null_value=args[0]->null_value))
return 0; /* purecov: inspected */ return 0; /* purecov: inspected */
...@@ -1483,17 +1484,17 @@ String *Item_func_format::val_str(String *str) ...@@ -1483,17 +1484,17 @@ String *Item_func_format::val_str(String *str)
if (str_length >= dec+4) if (str_length >= dec+4)
{ {
char *tmp,*pos; char *tmp,*pos;
length= str->length()+(diff=(str_length- dec-1)/3); length= str->length()+(diff= (int)(str_length- dec-1)/3);
str= copy_if_not_alloced(&tmp_str,str,length); str= copy_if_not_alloced(&tmp_str,str,length);
str->length(length); str->length(length);
tmp= (char*) str->ptr()+length - dec-1; tmp= (char*) str->ptr()+length - dec-1;
for (pos= (char*) str->ptr()+length-1; pos != tmp; pos--) for (pos= (char*) str->ptr()+length-1; pos != tmp; pos--)
pos[0]= pos[-(int) diff]; pos[0]= pos[-diff];
while (diff) while (diff)
{ {
pos[0]=pos[-(int) diff]; pos--; pos[0]=pos[-diff]; pos--;
pos[0]=pos[-(int) diff]; pos--; pos[0]=pos[-diff]; pos--;
pos[0]=pos[-(int) diff]; pos--; pos[0]=pos[-diff]; pos--;
pos[0]=','; pos[0]=',';
pos--; pos--;
diff--; diff--;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment