Signed-off-by: zhanghailiang <zhang.zhanghaili...@huawei.com>
---
 slirp/misc.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/slirp/misc.c b/slirp/misc.c
index b8eb74c..9b457ad 100644
--- a/slirp/misc.c
+++ b/slirp/misc.c
@@ -55,6 +55,10 @@ int add_exec(struct ex_list **ex_ptr, int do_pty, char *exec,
 
        tmp_ptr = *ex_ptr;
        *ex_ptr = (struct ex_list *)malloc(sizeof(struct ex_list));
+    if (*ex_ptr == NULL) {
+        fprintf(stderr, "Error: malloc failed\n");
+        return -1;
+    }
        (*ex_ptr)->ex_fport = port;
        (*ex_ptr)->ex_addr = addr;
        (*ex_ptr)->ex_pty = do_pty;
@@ -236,8 +240,9 @@ strdup(str)
        char *bptr;
 
        bptr = (char *)malloc(strlen(str)+1);
-       strcpy(bptr, str);
-
+    if (bptr) {
+        strcpy(bptr, str);
+    }
        return bptr;
 }
 #endif
-- 
1.7.12.4



Reply via email to