From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29333 invoked by alias); 1 Jul 2007 16:00:51 -0000 Received: (qmail 29311 invoked by uid 22791); 1 Jul 2007 16:00:41 -0000 X-Spam-Check-By: sourceware.org Received: from NaN.false.org (HELO nan.false.org) (208.75.86.248) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sun, 01 Jul 2007 16:00:39 +0000 Received: from nan.false.org (localhost [127.0.0.1]) by nan.false.org (Postfix) with ESMTP id ED998982BB; Sun, 1 Jul 2007 16:00:37 +0000 (GMT) Received: from caradoc.them.org (22.svnf5.xdsl.nauticom.net [209.195.183.55]) by nan.false.org (Postfix) with ESMTP id 93BED982B8; Sun, 1 Jul 2007 16:00:37 +0000 (GMT) Received: from drow by caradoc.them.org with local (Exim 4.67) (envelope-from ) id 1I51qJ-0003D7-BE; Sun, 01 Jul 2007 12:00:07 -0400 Date: Sun, 01 Jul 2007 16:00:00 -0000 From: Daniel Jacobowitz To: msnyder@sonic.net Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] null pointer guard, target-descriptions.c Message-ID: <20070701160007.GG10872@caradoc.them.org> Mail-Followup-To: msnyder@sonic.net, gdb-patches@sourceware.org References: <17674.12.7.175.2.1183064463.squirrel@webmail.sonic.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <17674.12.7.175.2.1183064463.squirrel@webmail.sonic.net> User-Agent: Mutt/1.5.15 (2007-04-09) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-07/txt/msg00012.txt.bz2 On Thu, Jun 28, 2007 at 02:01:03PM -0700, Michael Snyder wrote: > Possible null pointer ref, flagged by Coverity > > 2007-06-28 Michael Snyder > > * target-descriptions.c (tdesc-_named_type): Guard against null > type-id argument which may be passed by tdesc_create_reg (Coverity). Whoops, yeah - this one's my fault. There's another place in the same file which will crash if reg->type == NULL. How about we never set it to NULL instead? Like below. -- Daniel Jacobowitz CodeSourcery 2007-07-01 Daniel Jacobowitz * target-descriptions.c (tdesc_create_reg): Do not set reg->type to NULL. Index: target-descriptions.c =================================================================== RCS file: /cvs/src/src/gdb/target-descriptions.c,v retrieving revision 1.9 diff -u -p -r1.9 target-descriptions.c --- target-descriptions.c 13 Jun 2007 18:26:59 -0000 1.9 +++ target-descriptions.c 1 Jul 2007 15:59:10 -0000 @@ -792,7 +792,7 @@ tdesc_create_reg (struct tdesc_feature * reg->save_restore = save_restore; reg->group = group ? xstrdup (group) : NULL; reg->bitsize = bitsize; - reg->type = type ? xstrdup (type) : NULL; + reg->type = type ? xstrdup (type) : xstrdup (""); /* If the register's type is target-defined, look it up now. We may not have easy access to the containing feature when we want it later. */