Bug #2697 UDF functions, problem when printing out an error message
Submitted: 10 Feb 2004 3:15 Modified: 10 Feb 2004 3:17
Reporter: Jani Tolonen Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:4.1 OS:Any (All)
Assigned to: Jani Tolonen CPU Architecture:Any

[10 Feb 2004 3:15] Jani Tolonen
Description:
When an UDF function returned an error message, due to wrong
number of arguments for example, mysqld segmentation faulted.

How to repeat:
/* If my_udf() took only one argument, the following query would
   crash the server */
SELECT my_udf(1,2);

Suggested fix:
--- 1.183/sql/item_func.cc      Mon Feb  9 11:31:01 2004
+++ 1.184/sql/item_func.cc      Tue Feb 10 13:36:19 2004
@@ -1552,7 +1552,7 @@
     if ((error=(uchar) init(&initid, &f_args, thd->net.last_error)))
     {
       my_printf_error(ER_CANT_INITIALIZE_UDF,ER(ER_CANT_INITIALIZE_UDF),MYF(0),
-                     u_d->name,thd->net.last_error);
+                     u_d->name.str, thd->net.last_error);
       free_udf(u_d);
       DBUG_RETURN(1);
     }
@@ -1565,7 +1565,7 @@
   if (error)
   {
     my_printf_error(ER_CANT_INITIALIZE_UDF,ER(ER_CANT_INITIALIZE_UDF),MYF(0),
-                   u_d->name, ER(ER_UNKNOWN_ERROR));
+                   u_d->name.str, ER(ER_UNKNOWN_ERROR));
     DBUG_RETURN(1);
   }
   DBUG_RETURN(0);
[10 Feb 2004 3:17] Jani Tolonen
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

Fix will be in 4.1.2.