summaryrefslogtreecommitdiff
path: root/src/lib/emile
diff options
context:
space:
mode:
authorSrivardhan Hebbar <sri.hebbar@samsung.com>2015-10-22 12:19:01 -0700
committerCedric BAIL <cedric@osg.samsung.com>2015-10-22 12:20:55 -0700
commit444a0b11bcda66eb401d074770617c9d716ca6cb (patch)
tree3a096ae3ea9cf791aad071d5ca3b64073209efa4 /src/lib/emile
parentac3358b618b153ae62fc9c7de76491dbb6e2f344 (diff)
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>
Diffstat (limited to 'src/lib/emile')
-rw-r--r--src/lib/emile/emile_compress.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/lib/emile/emile_compress.c b/src/lib/emile/emile_compress.c
index f45546d85f..e2d23d4715 100644
--- a/src/lib/emile/emile_compress.c
+++ b/src/lib/emile/emile_compress.c
@@ -38,7 +38,7 @@ emile_compress(const Eina_Binbuf *data,
38 Emile_Compressor_Type t, 38 Emile_Compressor_Type t,
39 Emile_Compressor_Level l) 39 Emile_Compressor_Level l)
40{ 40{
41 void *compact; 41 void *compact, *temp;
42 int length; 42 int length;
43 int level = l; 43 int level = l;
44 Eina_Bool ok = EINA_FALSE; 44 Eina_Bool ok = EINA_FALSE;
@@ -55,19 +55,23 @@ emile_compress(const Eina_Binbuf *data,
55 length = LZ4_compress((const char *)eina_binbuf_string_get(data), 55 length = LZ4_compress((const char *)eina_binbuf_string_get(data),
56 compact, 56 compact,
57 eina_binbuf_length_get(data)); 57 eina_binbuf_length_get(data));
58 /* It is going to be smaller and should never fail, if it does you are in deep poo. */
59 temp = realloc(compact, length);
60 if (temp) temp = compact;
61
58 if (length > 0) 62 if (length > 0)
59 ok = EINA_TRUE; 63 ok = EINA_TRUE;
60 /* It is going to be smaller and should never fail, if it does you are in deep poo. */
61 compact = realloc(compact, length);
62 break; 64 break;
63 65
64 case EMILE_LZ4HC: 66 case EMILE_LZ4HC:
65 length = LZ4_compressHC((const char *)eina_binbuf_string_get(data), 67 length = LZ4_compressHC((const char *)eina_binbuf_string_get(data),
66 compact, 68 compact,
67 eina_binbuf_length_get(data)); 69 eina_binbuf_length_get(data));
70 temp = realloc(compact, length);
71 if (temp) compact = temp;
72
68 if (length > 0) 73 if (length > 0)
69 ok = EINA_TRUE; 74 ok = EINA_TRUE;
70 compact = realloc(compact, length);
71 break; 75 break;
72 76
73 case EMILE_ZLIB: 77 case EMILE_ZLIB: