mirror of
https://git.proxmox.com/git/qemu
synced 2025-08-08 11:22:52 +00:00
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>
This commit is contained in:
parent
a5cf8262e4
commit
bfad67399b
@ -643,7 +643,7 @@ static int cpu_sparc_find_by_name(sparc_def_t *cpu_def, const char *cpu_model)
|
|||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
const sparc_def_t *def = NULL;
|
const sparc_def_t *def = NULL;
|
||||||
char *s = strdup(cpu_model);
|
char *s = g_strdup(cpu_model);
|
||||||
char *featurestr, *name = strtok(s, ",");
|
char *featurestr, *name = strtok(s, ",");
|
||||||
uint32_t plus_features = 0;
|
uint32_t plus_features = 0;
|
||||||
uint32_t minus_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
|
#ifdef DEBUG_FEATURES
|
||||||
print_features(stderr, fprintf, cpu_def->features, NULL);
|
print_features(stderr, fprintf, cpu_def->features, NULL);
|
||||||
#endif
|
#endif
|
||||||
free(s);
|
g_free(s);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
Loading…
Reference in New Issue
Block a user