aboutsummaryrefslogtreecommitdiff
path: root/target-sparc/cpu.c
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2012-10-04 13:09:45 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2012-10-05 07:58:36 -0500
commitbfad67399bcca8c1afbbc93593d365044d92f7c6 (patch)
tree7eb73027506eca871ab9117a9103d4906757525c /target-sparc/cpu.c
parenta5cf8262e4eb9c4646434e2c6211ef8608db3233 (diff)
sparc: use g_strdup in place of unchecked strdup
This avoids a NULL-deref upon strdup failure. Also update matching free to g_free. Signed-off-by: Jim Meyering <meyering@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'target-sparc/cpu.c')
-rw-r--r--target-sparc/cpu.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/target-sparc/cpu.c b/target-sparc/cpu.c
index f7c004c7d8..eb9f0e7259 100644
--- a/target-sparc/cpu.c
+++ b/target-sparc/cpu.c
@@ -643,7 +643,7 @@ static int cpu_sparc_find_by_name(sparc_def_t *cpu_def, const char *cpu_model)
{
unsigned int i;
const sparc_def_t *def = NULL;
- char *s = strdup(cpu_model);
+ char *s = g_strdup(cpu_model);
char *featurestr, *name = strtok(s, ",");
uint32_t plus_features = 0;
uint32_t minus_features = 0;
@@ -735,7 +735,7 @@ static int cpu_sparc_find_by_name(sparc_def_t *cpu_def, const char *cpu_model)
#ifdef DEBUG_FEATURES
print_features(stderr, fprintf, cpu_def->features, NULL);
#endif
- free(s);
+ g_free(s);
return 0;
error: