]> Git Repo - qemu.git/commitdiff
linux-user: check return value of malloc()
authorzhanghailiang <[email protected]>
Thu, 14 Aug 2014 07:29:18 +0000 (15:29 +0800)
committerRiku Voipio <[email protected]>
Fri, 22 Aug 2014 12:06:35 +0000 (15:06 +0300)
Signed-off-by: zhanghailiang <[email protected]>
Acked-by: Riku Voipio <[email protected]>
Signed-off-by: Riku Voipio <[email protected]>
linux-user/syscall.c

index ebdc70e4ca54fb0b8b75395d05513903328f66a4..7ff7c2125536bc0087ccf427942527847bc1ad92 100644 (file)
@@ -2904,6 +2904,10 @@ static inline abi_long do_msgsnd(int msqid, abi_long msgp,
     if (!lock_user_struct(VERIFY_READ, target_mb, msgp, 0))
         return -TARGET_EFAULT;
     host_mb = malloc(msgsz+sizeof(long));
+    if (!host_mb) {
+        unlock_user_struct(target_mb, msgp, 0);
+        return -TARGET_ENOMEM;
+    }
     host_mb->mtype = (abi_long) tswapal(target_mb->mtype);
     memcpy(host_mb->mtext, target_mb->mtext, msgsz);
     ret = get_errno(msgsnd(msqid, host_mb, msgsz, msgflg));
This page took 0.043809 seconds and 4 git commands to generate.