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>
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;
}