summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2016-07-12 13:50:59 +0100
committerPeter Maydell <peter.maydell@linaro.org>2016-07-22 11:33:24 +0100
commit01a720125f5e2f0a23d2682b39dead2fcc820066 (patch)
tree58ee4815121e6ce5db432d42adfe363873c6e298
parente3643d32ee805d8a7b248526a507452c484a98e5 (diff)
target-sh4: Use glib allocator in movcal helper
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 <peter.maydell@linaro.org> Message-id: 1468327859-21385-1-git-send-email-peter.maydell@linaro.org Acked-by: Aurelien Jarno <aurelien@aurel32.net>
-rw-r--r--target-sh4/op_helper.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/target-sh4/op_helper.c b/target-sh4/op_helper.c
index 0204b0338f..684d3f3758 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;
}