eina_str: add null check condition in eina_memdup.

Summary:
Added null check in eina_memdup function in eina_str

Signed-off-by: vivek <vivek.ellur@samsung.com>

Reviewers: cedric

Subscribers: cedric

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

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This commit is contained in:
vivek 2015-02-20 11:40:43 +01:00 committed by Cedric BAIL
parent 3dda07dbce
commit 2ae90fd1ff
1 changed files with 4 additions and 0 deletions

View File

@ -668,8 +668,12 @@ eina_memdup(unsigned char *mem, size_t size, Eina_Bool terminate)
{
unsigned char *ret;
if (!mem) return NULL;
terminate = !!terminate;
ret = malloc(size + terminate);
if (!ret) return NULL;
memcpy(ret, mem, size);
if (terminate)
ret[size] = 0;