Commit afad1189 authored by unknown's avatar unknown

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

parent b04c1ad7
......@@ -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)
{
double nr =args[0]->val();
uint32 diff,length,str_length;
uint32 length,str_length;
int diff;
uint dec;
if ((null_value=args[0]->null_value))
return 0; /* purecov: inspected */
......@@ -1483,17 +1484,17 @@ String *Item_func_format::val_str(String *str)
if (str_length >= dec+4)
{
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->length(length);
tmp= (char*) str->ptr()+length - dec-1;
for (pos= (char*) str->ptr()+length-1; pos != tmp; pos--)
pos[0]= pos[-(int) diff];
pos[0]= pos[-diff];
while (diff)
{
pos[0]=pos[-(int) diff]; pos--;
pos[0]=pos[-(int) diff]; pos--;
pos[0]=pos[-(int) diff]; pos--;
pos[0]=pos[-diff]; pos--;
pos[0]=pos[-diff]; pos--;
pos[0]=pos[-diff]; pos--;
pos[0]=',';
pos--;
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