From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:48182) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SUdyS-0007dr-9Q for qemu-devel@nongnu.org; Wed, 16 May 2012 09:09:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SUdyL-0003eK-Tm for qemu-devel@nongnu.org; Wed, 16 May 2012 09:09:03 -0400 Received: from mx.meyering.net ([88.168.87.75]:35774 helo=hx.meyering.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SUdyL-0003e4-IQ for qemu-devel@nongnu.org; Wed, 16 May 2012 09:08:57 -0400 From: Jim Meyering Date: Wed, 16 May 2012 15:08:01 +0200 Message-Id: <1337173681-25891-7-git-send-email-jim@meyering.net> In-Reply-To: <1337173681-25891-1-git-send-email-jim@meyering.net> References: <1337173681-25891-1-git-send-email-jim@meyering.net> Subject: [Qemu-devel] [PATCH 6/6] softmmu-semi: fix lock_user* functions not to deref NULL upon OOM List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Anthony Liguori , Jim Meyering , Stefan Weil , Andreas F=E4rber , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Matthew Fernandez From: Jim Meyering Use g_malloc/g_free in place of malloc/free. Signed-off-by: Jim Meyering --- softmmu-semi.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/softmmu-semi.h b/softmmu-semi.h index 648cb95..996e0f7 100644 --- a/softmmu-semi.h +++ b/softmmu-semi.h @@ -39,7 +39,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); + p = g_malloc(len); if (copy) cpu_memory_rw_debug(env, addr, p, len, 0); return p; @@ -51,7 +51,7 @@ static char *softmmu_lock_user_string(CPUArchState *env, uint32_t addr) char *s; uint8_t c; /* TODO: Make this something that isn't fixed size. */ - s = p = malloc(1024); + s = p = g_malloc(1024); do { cpu_memory_rw_debug(env, addr, &c, 1, 0); addr++; @@ -65,6 +65,6 @@ static void softmmu_unlock_user(CPUArchState *env, void *p, target_ulong addr, { if (len) cpu_memory_rw_debug(env, addr, p, len, 1); - free(p); + g_free(p); } #define unlock_user(s, args, len) softmmu_unlock_user(env, s, args, len) -- 1.7.10.2.520.g6a4a482