Commit f7adc4a1 authored by Oleksandr Byelkin's avatar Oleksandr Byelkin

A bit more safety

parent 0ec641ea
...@@ -501,7 +501,10 @@ public: ...@@ -501,7 +501,10 @@ public:
String str2(buff2, sizeof(buff2), charset), *res; String str2(buff2, sizeof(buff2), charset), *res;
if (!(res=var->value->val_str(&str))) if (!(res=var->value->val_str(&str)))
{
var->save_result.string_value.str= 0; var->save_result.string_value.str= 0;
var->save_result.string_value.length= 0; // safety
}
else else
{ {
uint32 unused; uint32 unused;
...@@ -895,9 +898,16 @@ public: ...@@ -895,9 +898,16 @@ public:
String str(buff, sizeof(buff), system_charset_info), *res; String str(buff, sizeof(buff), system_charset_info), *res;
if (!(res=var->value->val_str(&str))) if (!(res=var->value->val_str(&str)))
{
var->save_result.string_value.str= const_cast<char*>(""); var->save_result.string_value.str= const_cast<char*>("");
var->save_result.string_value.length= 0;
}
else 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; return false;
} }
bool session_update(THD *thd, set_var *var) bool session_update(THD *thd, set_var *var)
...@@ -921,6 +931,7 @@ public: ...@@ -921,6 +931,7 @@ public:
{ {
char *ptr= (char*)(intptr)option.def_value; char *ptr= (char*)(intptr)option.def_value;
var->save_result.string_value.str= ptr; 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) uchar *session_value_ptr(THD *thd, const LEX_CSTRING *base)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment