edje: use realloc instead of malloc and memcpy.
authorSrivardhan Hebbar <sri.hebbar@samsung.com>
Fri, 12 Dec 2014 03:22:49 +0000 (04:22 +0100)
committerCedric BAIL <cedric@osg.samsung.com>
Fri, 12 Dec 2014 03:22:54 +0000 (04:22 +0100)
Summary:
Replaced malloc with realloc. Removed free. Added a Error message.

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

Reviewed By: cedric

Subscribers: devilhorns, cedric

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

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
src/bin/edje/edje_cc_out.c

index 455516b..16c0293 100755 (executable)
@@ -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;
 }