Commit 50254237 authored by ram@gw.mysql.r18.ru's avatar ram@gw.mysql.r18.ru

Fix for the bug #1333: COMPRESS(NULL) segfaults.

parent 7facccf3
...@@ -97,6 +97,7 @@ peter@linux.local ...@@ -97,6 +97,7 @@ peter@linux.local
peter@mysql.com peter@mysql.com
peterg@mysql.com peterg@mysql.com
pgulutzan@linux.local pgulutzan@linux.local
ram@gw.mysql.r18.ru
ram@gw.udmsearch.izhnet.ru ram@gw.udmsearch.izhnet.ru
ram@mysql.r18.ru ram@mysql.r18.ru
ram@ram.(none) ram@ram.(none)
......
...@@ -40,3 +40,9 @@ uncompress(compress("")) ...@@ -40,3 +40,9 @@ uncompress(compress(""))
select uncompressed_length(""); select uncompressed_length("");
uncompressed_length("") uncompressed_length("")
0 0
select compress(NULL);
compress(NULL)
NULL
select uncompress(NULL);
uncompress(NULL)
NULL
...@@ -23,3 +23,9 @@ select uncompress(""); ...@@ -23,3 +23,9 @@ select uncompress("");
select uncompress(compress("")); select uncompress(compress(""));
select uncompressed_length(""); select uncompressed_length("");
#
# NULL (Bug #1333)
#
select compress(NULL);
select uncompress(NULL);
...@@ -2539,6 +2539,11 @@ longlong Item_func_crc32::val_int() ...@@ -2539,6 +2539,11 @@ longlong Item_func_crc32::val_int()
String *Item_func_compress::val_str(String *str) String *Item_func_compress::val_str(String *str)
{ {
String *res= args[0]->val_str(str); String *res= args[0]->val_str(str);
if (!res)
{
null_value= 1;
return 0;
}
if (res->is_empty()) return res; if (res->is_empty()) return res;
int err= Z_OK; int err= Z_OK;
...@@ -2589,6 +2594,11 @@ String *Item_func_compress::val_str(String *str) ...@@ -2589,6 +2594,11 @@ String *Item_func_compress::val_str(String *str)
String *Item_func_uncompress::val_str(String *str) String *Item_func_uncompress::val_str(String *str)
{ {
String *res= args[0]->val_str(str); String *res= args[0]->val_str(str);
if (!res)
{
null_value= 1;
return 0;
}
if (res->is_empty()) return res; if (res->is_empty()) return res;
ulong new_size= uint4korr(res->c_ptr()) & 0x3FFFFFFF; ulong new_size= uint4korr(res->c_ptr()) & 0x3FFFFFFF;
......
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