From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44632) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bMx9Y-0005Lo-JK for qemu-devel@nongnu.org; Tue, 12 Jul 2016 08:51:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bMx9U-0004sJ-KA for qemu-devel@nongnu.org; Tue, 12 Jul 2016 08:51:08 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:58280) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bMx9U-0004s0-CI for qemu-devel@nongnu.org; Tue, 12 Jul 2016 08:51:04 -0400 From: Peter Maydell Date: Tue, 12 Jul 2016 13:50:59 +0100 Message-Id: <1468327859-21385-1-git-send-email-peter.maydell@linaro.org> Subject: [Qemu-devel] [PATCH] target-sh4: Use glib allocator in movcal helper List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: patches@linaro.org, Aurelien Jarno Coverity spots that helper_movcal() calls malloc() but doesn't check for failure. Fix this by switching to the glib allocation functions, which abort on allocation failure. Signed-off-by: Peter Maydell --- target-sh4/op_helper.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/target-sh4/op_helper.c b/target-sh4/op_helper.c index 303e83e..40dd1cf 100644 --- a/target-sh4/op_helper.c +++ b/target-sh4/op_helper.c @@ -109,7 +109,8 @@ void helper_movcal(CPUSH4State *env, uint32_t address, uint32_t value) { if (cpu_sh4_is_cached (env, address)) { - memory_content *r = malloc (sizeof(memory_content)); + memory_content *r = g_new(memory_content, 1); + r->address = address; r->value = value; r->next = NULL; @@ -126,7 +127,7 @@ void helper_discard_movcal_backup(CPUSH4State *env) while(current) { memory_content *next = current->next; - free (current); + g_free(current); env->movcal_backup = current = next; if (current == NULL) env->movcal_backup_tail = &(env->movcal_backup); @@ -149,7 +150,7 @@ void helper_ocbi(CPUSH4State *env, uint32_t address) env->movcal_backup_tail = current; } - free (*current); + g_free(*current); *current = next; break; } -- 1.9.1