MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Bjorn Munch Date:October 17 2009 10:43am
Subject:bzr commit into mysql-6.0-mtr branch (Bjorn.Munch:2869) Bug#47851
View as plain text  
#At file:///home/bm136801/my/upmerge-60/ based on revid:bjorn.munch@stripped

 2869 Bjorn Munch	2009-10-17
      Bug#47851 - main.ps_ddl1 and funcs_1.storedproc fail with signal 11
      The named test cases failed with a crash in the mysqltest utility.
      The reason was an attempted my_free() of memeory, previously
      allocated with my_once_strdup().
      Memory allocated with my_once_*() must not be freed. Least of all
      with my_free().
      Since setting environment strings is not a frequent operation,
      we can live with the leak.
      @ client/
        Bug#47851 - main.ps_ddl1 and funcs_1.storedproc fail with signal 11
        Avoid freeing of memory allocated by my_once_strdup().
        Add comment explaining why we don't free v->env_s

=== modified file 'client/'
--- a/client/	2009-10-08 12:24:36 +0000
+++ b/client/	2009-10-17 10:39:49 +0000
@@ -1952,6 +1952,7 @@ VAR *var_init(VAR *v, const char *name, 
 void var_free(void *v)
   my_free(((VAR*) v)->str_val, MYF(MY_WME));
+  /* It is not safe to free v->env_s as it has been sent to putenv() */
   if (((VAR*)v)->alloced)
     my_free(v, MYF(MY_WME));
@@ -2072,7 +2073,7 @@ void var_set(const char *var_name, const
   if (env_var)
-    char buf[1024], *old_env_s= v->env_s;
+    char buf[1024]; 
     if (v->int_dirty)
       sprintf(v->str_val, "%d", v->int_val);
@@ -2082,10 +2083,13 @@ void var_set(const char *var_name, const
     my_snprintf(buf, sizeof(buf), "%.*s=%.*s",
                 v->name_len, v->name,
                 v->str_val_len, v->str_val);
+    /*
+      NOTE: We overwrite a possibly previously allocated value.
+      We cannot free memory that was allocated with my_once_*().
+    */
     if (!(v->env_s= my_once_strdup(buf, MYF(MY_WME))))
       die("Out of memory");
-    my_free(old_env_s, MYF(MY_ALLOW_ZERO_PTR));

Attachment: [text/bzr-bundle] bzr/
bzr commit into mysql-6.0-mtr branch (Bjorn.Munch:2869) Bug#47851Bjorn Munch17 Oct