]> git.proxmox.com Git - qemu.git/commitdiff
softmmu-semi: fix lock_user* functions not to deref NULL upon OOM
authorJim Meyering <meyering@redhat.com>
Wed, 22 Aug 2012 11:55:56 +0000 (13:55 +0200)
committerAnthony Liguori <aliguori@us.ibm.com>
Wed, 22 Aug 2012 15:47:14 +0000 (10:47 -0500)
Return NULL upon malloc failure.

Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
softmmu-semi.h

index 648cb959d8f84125ec1c26488e8cb6c9c8294589..bcb979a5b037d847f2639949b94a02068b9e425a 100644 (file)
@@ -40,7 +40,7 @@ static void *softmmu_lock_user(CPUArchState *env, uint32_t addr, uint32_t len,
     uint8_t *p;
     /* TODO: Make this something that isn't fixed size.  */
     p = malloc(len);
-    if (copy)
+    if (p && copy)
         cpu_memory_rw_debug(env, addr, p, len, 0);
     return p;
 }
@@ -52,6 +52,9 @@ static char *softmmu_lock_user_string(CPUArchState *env, uint32_t addr)
     uint8_t c;
     /* TODO: Make this something that isn't fixed size.  */
     s = p = malloc(1024);
+    if (!s) {
+        return NULL;
+    }
     do {
         cpu_memory_rw_debug(env, addr, &c, 1, 0);
         addr++;