emile: handling memory leak on realloc.

Summary: Signed-off-by: Srivardhan Hebbar <sri.hebbar@samsung.com>

Reviewers: cedric

Differential Revision: https://phab.enlightenment.org/D3210

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This commit is contained in:
Srivardhan Hebbar 2015-10-22 12:19:01 -07:00 committed by Cedric BAIL
parent ac3358b618
commit 444a0b11bc
1 changed files with 8 additions and 4 deletions

View File

@ -38,7 +38,7 @@ emile_compress(const Eina_Binbuf *data,
Emile_Compressor_Type t,
Emile_Compressor_Level l)
{
void *compact;
void *compact, *temp;
int length;
int level = l;
Eina_Bool ok = EINA_FALSE;
@ -55,19 +55,23 @@ emile_compress(const Eina_Binbuf *data,
length = LZ4_compress((const char *)eina_binbuf_string_get(data),
compact,
eina_binbuf_length_get(data));
/* It is going to be smaller and should never fail, if it does you are in deep poo. */
temp = realloc(compact, length);
if (temp) temp = compact;
if (length > 0)
ok = EINA_TRUE;
/* It is going to be smaller and should never fail, if it does you are in deep poo. */
compact = realloc(compact, length);
break;
case EMILE_LZ4HC:
length = LZ4_compressHC((const char *)eina_binbuf_string_get(data),
compact,
eina_binbuf_length_get(data));
temp = realloc(compact, length);
if (temp) compact = temp;
if (length > 0)
ok = EINA_TRUE;
compact = realloc(compact, length);
break;
case EMILE_ZLIB: