Bug #284 FORMAT('nan',2) makes the server restart/crash
Submitted: 13 Apr 2003 19:29 Modified: 14 Apr 2003 11:17
Reporter: Arjen Lentz Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:4.0.12 OS:Linux (Linux)
Assigned to: CPU Architecture:Any

[13 Apr 2003 19:29] Arjen Lentz
Description:
(copied from an old manual comment - the problem still exists in 4.0.12 on Linux)

SELECT FORMAT('nan',2);
makes the server restart/crash, while
SELECT FORMAT('dontcrash',2);
doesn't.

How to repeat:
SELECT FORMAT('nan',2);
crashes the server.
[13 Apr 2003 19:31] Arjen Lentz
If possible, this should probably also be fixed in the 3.23 tree (that is what the original report referred to 3.23.45)
[14 Apr 2003 11:17] MySQL Verification Team
===== /mnt/work/mysql-4.0/sql/item_strfunc.cc 1.56 vs edited =====
*** /tmp/item_strfunc.cc-1.56-15639     Sun Mar 30 16:35:24 2003
--- edited//mnt/work/mysql-4.0/sql/item_strfunc.cc      Mon Apr 14 21:12:25 2003
***************
*** 1477,1483 ****
    if (nr < 0)
      str_length--;                             // Don't count sign
    length=str->length()+(diff=(str_length- dec-1)/3);
!   if (diff)
    {
      char *tmp,*pos;
      str=copy_if_not_alloced(&tmp_str,str,length);
--- 1477,1483 ----
    if (nr < 0)
      str_length--;                             // Don't count sign
    length=str->length()+(diff=(str_length- dec-1)/3);
!   if (diff && diff < 330) // size of buff ...
    {
      char *tmp,*pos;
      str=copy_if_not_alloced(&tmp_str,str,length);