mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 04:22:27 +01:00
Fix for bug#8978 : Crash on 'select format ...'
This commit is contained in:
parent
32773212f5
commit
fd35e7870a
1 changed files with 7 additions and 6 deletions
|
@ -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--;
|
||||
|
|
Loading…
Reference in a new issue