eina_str: add null check condition in eina_memdup.
authorvivek <vivek.ellur@samsung.com>
Fri, 20 Feb 2015 10:40:43 +0000 (11:40 +0100)
committerCedric BAIL <cedric@osg.samsung.com>
Fri, 20 Feb 2015 10:42:13 +0000 (11:42 +0100)
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>
src/lib/eina/eina_str.c

index 770a64404955892c73feac213fb0f3aee40b804f..e1445f21208be963601f9d5c38b2c12709e8d905 100644 (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;