diff options
author | ram@gw.mysql.r18.ru <> | 2004-09-13 18:43:59 +0500 |
---|---|---|
committer | ram@gw.mysql.r18.ru <> | 2004-09-13 18:43:59 +0500 |
commit | a3a6b7fa252d34f5555d4ed8d9316aa03385e70c (patch) | |
tree | 97f19b42f2ec23bb89b1aefe61430cb1b1998163 /sql/item_strfunc.cc | |
parent | ca0fc0b4f4a5c990c94474b99dd66900b46ad14d (diff) | |
download | mariadb-git-a3a6b7fa252d34f5555d4ed8d9316aa03385e70c.tar.gz |
A fix (bug #5497: COMPRESS() returns NULL for large strings).
Diffstat (limited to 'sql/item_strfunc.cc')
-rw-r--r-- | sql/item_strfunc.cc | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index fac73a1a759..cf2fe137d05 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -2723,11 +2723,17 @@ String *Item_func_compress::val_str(String *str) compress(compress(compress(...))) I.e. zlib give number 'at least'.. */ - ulong new_size= (ulong)((res->length()*120)/100)+12; + ulong new_size= res->length() + res->length() / 5 + 12; - buffer.realloc((uint32)new_size + 4 + 1); - Byte *body= ((Byte*)buffer.ptr()) + 4; + // Will check new_size overflow: new_size <= res->length() + if (((uint32) new_size <= res->length()) || + buffer.realloc((uint32) new_size + 4 + 1)) + { + null_value= 1; + return 0; + } + Byte *body= ((Byte*)buffer.ptr()) + 4; // As far as we have checked res->is_empty() we can use ptr() if ((err= compress(body, &new_size, |