diff options
author | Alfranio Correia <alfranio.correia@sun.com> | 2008-12-13 19:42:12 +0000 |
---|---|---|
committer | Alfranio Correia <alfranio.correia@sun.com> | 2008-12-13 19:42:12 +0000 |
commit | 19f859a27e60270f3cdc7e2edc34e88c29536c21 (patch) | |
tree | 3ca8c469534126c025304d8d96dbeb2b359a6c00 /sql/sql_class.cc | |
parent | 5c16a315ca28c18949e27b91cddf0886329d1dd4 (diff) | |
parent | ba816c14a9bc8012759da9d58f858f1e73bec708 (diff) | |
download | mariadb-git-19f859a27e60270f3cdc7e2edc34e88c29536c21.tar.gz |
merge 5.1 --> 5.1-rpl
Diffstat (limited to 'sql/sql_class.cc')
-rw-r--r-- | sql/sql_class.cc | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 15501ec2f09..66cafd68212 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -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, char *buffer, unsigned int length, } 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; } /** |