cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=9792943910fedb834c7ec61f92a17a0810248bc7

commit 9792943910fedb834c7ec61f92a17a0810248bc7
Author: Srivardhan Hebbar <[email protected]>
Date:   Fri Dec 12 04:22:49 2014 +0100

    edje: use realloc instead of malloc and memcpy.
    
    Summary:
    Replaced malloc with realloc. Removed free. Added a Error message.
    
    Signed-off-by: Srivardhan Hebbar <[email protected]>
    
    Reviewers: cedric
    
    Reviewed By: cedric
    
    Subscribers: devilhorns, cedric
    
    Differential Revision: https://phab.enlightenment.org/D1766
    
    Signed-off-by: Cedric BAIL <[email protected]>
---
 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;
 }

-- 


Reply via email to