cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=2ae90fd1ffce5ee5c3cb6ed78766792166290371

commit 2ae90fd1ffce5ee5c3cb6ed78766792166290371
Author: vivek <[email protected]>
Date:   Fri Feb 20 11:40:43 2015 +0100

    eina_str: add null check condition in eina_memdup.
    
    Summary:
    Added null check in eina_memdup function in eina_str
    
    Signed-off-by: vivek <[email protected]>
    
    Reviewers: cedric
    
    Subscribers: cedric
    
    Differential Revision: https://phab.enlightenment.org/D1997
    
    Signed-off-by: Cedric BAIL <[email protected]>
---
 src/lib/eina/eina_str.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/lib/eina/eina_str.c b/src/lib/eina/eina_str.c
index 770a644..e1445f2 100644
--- a/src/lib/eina/eina_str.c
+++ b/src/lib/eina/eina_str.c
@@ -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;

-- 


Reply via email to