diff options
author | Oleksandr Byelkin <sanja@mariadb.com> | 2020-07-22 10:30:00 +0200 |
---|---|---|
committer | Oleksandr Byelkin <sanja@mariadb.com> | 2020-07-23 09:38:58 +0200 |
commit | f7adc4a11d36d7a75ba82d658121cb263f5b78c7 (patch) | |
tree | 6f21d0cdb6258df023c529d66d11a87fa971e173 /sql/sys_vars.ic | |
parent | 0ec641ea1ef1ef23183d8c1b4e6d9e4a9810eba2 (diff) | |
download | mariadb-git-f7adc4a11d36d7a75ba82d658121cb263f5b78c7.tar.gz |
A bit more safety
Diffstat (limited to 'sql/sys_vars.ic')
-rw-r--r-- | sql/sys_vars.ic | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/sql/sys_vars.ic b/sql/sys_vars.ic index ec8d9ef201a..860502c40e3 100644 --- a/sql/sys_vars.ic +++ b/sql/sys_vars.ic @@ -501,7 +501,10 @@ public: String str2(buff2, sizeof(buff2), charset), *res; if (!(res=var->value->val_str(&str))) + { var->save_result.string_value.str= 0; + var->save_result.string_value.length= 0; // safety + } else { uint32 unused; @@ -895,9 +898,16 @@ public: String str(buff, sizeof(buff), system_charset_info), *res; if (!(res=var->value->val_str(&str))) + { var->save_result.string_value.str= const_cast<char*>(""); + var->save_result.string_value.length= 0; + } else - var->save_result.string_value.str= thd->strmake(res->ptr(), res->length()); + { + size_t len= res->length(); + var->save_result.string_value.str= thd->strmake(res->ptr(), len); + var->save_result.string_value.length= len; + } return false; } bool session_update(THD *thd, set_var *var) @@ -921,6 +931,7 @@ public: { char *ptr= (char*)(intptr)option.def_value; var->save_result.string_value.str= ptr; + var->save_result.string_value.length= safe_strlen(ptr); } uchar *session_value_ptr(THD *thd, const LEX_CSTRING *base) { |