1
0
mirror of https://github.com/MariaDB/server.git synced 2025-09-02 09:41:40 +03:00

A fix (bug #5497: COMPRESS() returns NULL for large strings).

This commit is contained in:
ram@gw.mysql.r18.ru
2004-09-13 18:43:59 +05:00
parent ca0fc0b4f4
commit a3a6b7fa25
3 changed files with 20 additions and 3 deletions

View File

@@ -2723,12 +2723,18 @@ 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;
// 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;
}
buffer.realloc((uint32)new_size + 4 + 1);
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,
(const Bytef*)res->ptr(), res->length())) != Z_OK)