MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Alexander Nozdrin Date:January 11 2010 4:44pm
Subject:bzr commit into mysql-5.5-next-mr-bugfixing branch (alik:2963)
Bug#50120
View as plain text  
#At file:///mnt/raid/alik/MySQL/bzr/00.builds/mysql-next-mr-bugfixing/ based on revid:alik@stripped

 2963 Alexander Nozdrin	2010-01-11
      Backporting revision from mysql-6.0-codebase-bugfixing.
      Original revision:
      ------------------------------------------------------------
      revno: 3817
      revision-id: guilhem@stripped
      parent: guilhem@stripped
      committer: Guilhem Bichot <guilhem@stripped>
      branch nick: mysql-6.0-codebase-bugfixing
      timestamp: Fri 2010-01-08 10:27:56 +0100
      message:
        fix for BUG#50120 "Valgrind errors in any test, inside mysqltest"
        Problem was that as v->name[v->name_len] may be uninitialized (which is ok per se),
        it shouldn't be used in an if(). We remove this zero_the_char/restore_it logic by
        rather zero-terminating the v->name string when we create it in var_init().
      ------------------------------------------------------------

    modified:
      client/mysqltest.cc
=== modified file 'client/mysqltest.cc'
--- a/client/mysqltest.cc	2010-01-11 16:42:35 +0000
+++ b/client/mysqltest.cc	2010-01-11 16:43:55 +0000
@@ -1927,13 +1927,20 @@ VAR *var_init(VAR *v, const char *name, 
                                                   + name_len+1, MYF(MY_WME))))
     die("Out of memory");
 
-  tmp_var->name = (name) ? (char*) tmp_var + sizeof(*tmp_var) : 0;
+  if (name != NULL)
+  {
+    tmp_var->name= reinterpret_cast<char*>(tmp_var) + sizeof(*tmp_var);
+    memcpy(tmp_var->name, name, name_len);
+    tmp_var->name[name_len]= 0;
+  }
+  else
+    tmp_var->name= NULL;
+
   tmp_var->alloced = (v == 0);
 
   if (!(tmp_var->str_val = (char*)my_malloc(val_alloc_len+1, MYF(MY_WME))))
     die("Out of memory");
 
-  memcpy(tmp_var->name, name, name_len);
   if (val)
   {
     memcpy(tmp_var->str_val, val, val_len);
@@ -2077,12 +2084,9 @@ void var_set(const char *var_name, const
       v->int_dirty= 0;
       v->str_val_len= strlen(v->str_val);
     }
-    char oldc= v->name[v->name_len];
-    if (oldc)
-      v->name[v->name_len]= 0;   // setenv() expects \0-terminated strings
-    setenv(v->name, v->str_val, 1); // v->str_val is always \0-terminated
-    if (oldc)
-      v->name[v->name_len]= oldc;
+    /* setenv() expects \0-terminated strings */
+    DBUG_ASSERT(v->name[v->name_len] == 0);
+    setenv(v->name, v->str_val, 1);
   }
   DBUG_VOID_RETURN;
 }


Attachment: [text/bzr-bundle] bzr/alik@sun.com-20100111164355-pbjn3jcxvwkryiua.bundle
Thread
bzr commit into mysql-5.5-next-mr-bugfixing branch (alik:2963)Bug#50120Alexander Nozdrin11 Jan