forked from enlightenment/efl
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:
parent
3dda07dbce
commit
2ae90fd1ff
|
@ -668,8 +668,12 @@ eina_memdup(unsigned char *mem, size_t size, Eina_Bool terminate)
|
||||||
{
|
{
|
||||||
unsigned char *ret;
|
unsigned char *ret;
|
||||||
|
|
||||||
|
if (!mem) return NULL;
|
||||||
|
|
||||||
terminate = !!terminate;
|
terminate = !!terminate;
|
||||||
ret = malloc(size + terminate);
|
ret = malloc(size + terminate);
|
||||||
|
if (!ret) return NULL;
|
||||||
|
|
||||||
memcpy(ret, mem, size);
|
memcpy(ret, mem, size);
|
||||||
if (terminate)
|
if (terminate)
|
||||||
ret[size] = 0;
|
ret[size] = 0;
|
||||||
|
|
Loading…
Reference in New Issue