From 9792943910fedb834c7ec61f92a17a0810248bc7 Mon Sep 17 00:00:00 2001 From: Srivardhan Hebbar Date: Fri, 12 Dec 2014 04:22:49 +0100 Subject: [PATCH] edje: use realloc instead of malloc and memcpy. Summary: Replaced malloc with realloc. Removed free. Added a Error message. Signed-off-by: Srivardhan Hebbar Reviewers: cedric Reviewed By: cedric Subscribers: devilhorns, cedric Differential Revision: https://phab.enlightenment.org/D1766 Signed-off-by: Cedric BAIL --- src/bin/edje/edje_cc_out.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/bin/edje/edje_cc_out.c b/src/bin/edje/edje_cc_out.c index 455516b..16c0293 100755 --- a/src/bin/edje/edje_cc_out.c +++ b/src/bin/edje/edje_cc_out.c @@ -1566,13 +1566,20 @@ _edje_lua_script_writer(lua_State *L EINA_UNUSED, const void *chunk_buf, size_t Script_Lua_Writer *data; void *old; + data = (Script_Lua_Writer *)_data; old = data->buf; - data->buf = malloc(data->size + chunk_size); - memcpy(data->buf, old, data->size); - memcpy(&((data->buf)[data->size]), chunk_buf, chunk_size); - if (old) free(old); - data->size += chunk_size; + data->buf = realloc(data->buf, data->size + chunk_size); + if (data->buf) + { + memcpy(&((data->buf)[data->size]), chunk_buf, chunk_size); + data->size += chunk_size; + } + else + { + ERR("Failed to copy chunk buffer.\n"); + data->buf = old; + } return 0; } -- 2.7.4