This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] null pointer guard, target-descriptions.c


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  <msnyder@access-company.com>
> 
> 	* 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  <dan@codesourcery.com>

	* 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 ("<unknown>");
 
   /* 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.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]