[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCHv3 02/20] sparc: use g_strdup in place of unchecked s
From: |
Jim Meyering |
Subject: |
[Qemu-devel] [PATCHv3 02/20] sparc: use g_strdup in place of unchecked strdup |
Date: |
Thu, 4 Oct 2012 13:09:45 +0200 |
From: Jim Meyering <address@hidden>
This avoids a NULL-deref upon strdup failure.
Also update matching free to g_free.
Signed-off-by: Jim Meyering <address@hidden>
---
target-sparc/cpu.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/target-sparc/cpu.c b/target-sparc/cpu.c
index f7c004c..eb9f0e7 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:
--
1.8.0.rc0.18.gf84667d
- [Qemu-devel] [PATCHv3 00/20] strncpy: best avoided, Jim Meyering, 2012/10/04
- [Qemu-devel] [PATCHv3 01/20] scsi, pci, qdev, isa-bus, sysbus: don't let *_get_fw_dev_path return NULL, Jim Meyering, 2012/10/04
- [Qemu-devel] [PATCHv3 02/20] sparc: use g_strdup in place of unchecked strdup,
Jim Meyering <=
- [Qemu-devel] [PATCHv3 03/20] block: avoid buffer overrun by using pstrcpy, not strncpy, Jim Meyering, 2012/10/04
- [Qemu-devel] [PATCHv3 05/20] vmdk: relative_path: use pstrcpy in place of strncpy, Jim Meyering, 2012/10/04
- [Qemu-devel] [PATCHv3 06/20] hw/9pfs: avoid buffer overrun, Jim Meyering, 2012/10/04
- [Qemu-devel] [PATCHv3 04/20] sheepdog: avoid a few buffer overruns, Jim Meyering, 2012/10/04
- [Qemu-devel] [PATCHv3 07/20] lm32: avoid buffer overrun, Jim Meyering, 2012/10/04
- [Qemu-devel] [PATCHv3 10/20] linux-user: remove two unchecked uses of strdup, Jim Meyering, 2012/10/04
- [Qemu-devel] [PATCHv3 08/20] os-posix: avoid buffer overrun, Jim Meyering, 2012/10/04
- [Qemu-devel] [PATCHv3 09/20] ppc: avoid buffer overrun: use pstrcpy, not strncpy, Jim Meyering, 2012/10/04
- [Qemu-devel] [PATCHv3 12/20] bt: replace fragile snprintf use and unwarranted strncpy, Jim Meyering, 2012/10/04
- [Qemu-devel] [PATCHv3 11/20] ui/vnc: simplify and avoid strncpy, Jim Meyering, 2012/10/04
- Prev by Date:
[Qemu-devel] [PATCHv3 01/20] scsi, pci, qdev, isa-bus, sysbus: don't let *_get_fw_dev_path return NULL
- Next by Date:
[Qemu-devel] [PATCHv3 03/20] block: avoid buffer overrun by using pstrcpy, not strncpy
- Previous by thread:
Re: [Qemu-devel] [PATCHv3 01/20] scsi, pci, qdev, isa-bus, sysbus: don't let *_get_fw_dev_path return NULL
- Next by thread:
[Qemu-devel] [PATCHv3 03/20] block: avoid buffer overrun by using pstrcpy, not strncpy
- Index(es):