From: Date: November 17 2008 3:13pm Subject: bzr commit into mysql-5.1 branch (kristofer.pettersson:2704) List-Archive: http://lists.mysql.com/commits/58958 Message-Id: <0KAH0082EE6DK4D0@fe-emea-09.sun.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7BIT #At file:///home/thek/Development/cpp/mysqlbzr/mysql-5.1-bugteam/ 2704 Kristofer Pettersson 2008-11-17 [merge] Automerge modified: sql/sql_class.cc === modified file 'sql/sql_class.cc' --- a/sql/sql_class.cc 2008-11-07 13:52:43 +0000 +++ b/sql/sql_class.cc 2008-11-17 14:22:29 +0000 @@ -311,7 +311,7 @@ void thd_inc_row_count(THD *thd) Dumps a text description of a thread, its security context (user, host) and the current query. - @param thd current thread context + @param thd thread context @param buffer pointer to preferred result buffer @param length length of buffer @param max_query_len how many chars of query to copy (0 for all) @@ -385,7 +385,17 @@ char *thd_security_context(THD *thd, cha } if (str.c_ptr_safe() == buffer) return buffer; - return thd->strmake(str.ptr(), str.length()); + + /* + We have to copy the new string to the destination buffer because the string + was reallocated to a larger buffer to be able to fit. + */ + DBUG_ASSERT(buffer != NULL); + length= min(str.length(), length-1); + memcpy(buffer, str.c_ptr_quick(), length); + /* Make sure that the new string is null terminated */ + buffer[length]= '\0'; + return buffer; } /**