Received: from eggs.gnu.org ([208.118.235.92]:59195) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TJjKP-0002Ii-B4 for qemu-devel@nongnu.org; Thu, 04 Oct 2012 07:10:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TJjKN-0003FN-B0 for qemu-devel@nongnu.org; Thu, 04 Oct 2012 07:10:52 -0400 Received: from mx.meyering.net ([88.168.87.75]:56997 helo=hx.meyering.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TJjKM-0003FE-VB for qemu-devel@nongnu.org; Thu, 04 Oct 2012 07:10:51 -0400 From: Jim Meyering Date: Thu, 4 Oct 2012 13:09:45 +0200 Message-Id: <1349349003-15672-3-git-send-email-jim@meyering.net> In-Reply-To: <1349349003-15672-1-git-send-email-jim@meyering.net> References: <1349349003-15672-1-git-send-email-jim@meyering.net> Subject: [Qemu-devel] [PATCHv3 02/20] sparc: use g_strdup in place of unchecked strdup List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Jim Meyering From: Jim Meyering This avoids a NULL-deref upon strdup failure. Also update matching free to g_free. Signed-off-by: Jim Meyering --- 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