提交 15d9e3bc 编写于 作者: J Jim Meyering 提交者: Anthony Liguori

softmmu-semi: fix lock_user* functions not to deref NULL upon OOM

Return NULL upon malloc failure.
Signed-off-by: NJim Meyering <meyering@redhat.com>
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 396bef4b
......@@ -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++;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册