Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] null pointer guard, target-descriptions.c
@ 2007-06-28 21:12 msnyder
  2007-07-01 16:00 ` Daniel Jacobowitz
  0 siblings, 1 reply; 4+ messages in thread
From: msnyder @ 2007-06-28 21:12 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 48 bytes --]

Possible null pointer ref, flagged by Coverity


[-- Attachment #2: tdesc --]
[-- Type: application/octet-stream, Size: 3207 bytes --]

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).

Index: target-descriptions.c
===================================================================
RCS file: /cvs/src/src/gdb/target-descriptions.c,v
retrieving revision 1.9
diff -p -r1.9 target-descriptions.c
*** target-descriptions.c	13 Jun 2007 18:26:59 -0000	1.9
--- target-descriptions.c	28 Jun 2007 20:57:07 -0000
*************** tdesc_named_type (const struct tdesc_fea
*** 350,396 ****
    int ix;
    struct type *gdb_type;
  
!   /* First try target-defined types.  */
!   for (ix = 0; VEC_iterate (type_p, feature->types, ix, gdb_type); ix++)
!     if (strcmp (TYPE_NAME (gdb_type), id) == 0)
!       return gdb_type;
! 
!   /* Next try some predefined types.  Note that none of these types
!      depend on the current architecture; some of the builtin_type_foo
!      variables are swapped based on the architecture.  */
!   if (strcmp (id, "int8") == 0)
!     return builtin_type_int8;
  
!   if (strcmp (id, "int16") == 0)
!     return builtin_type_int16;
  
!   if (strcmp (id, "int32") == 0)
!     return builtin_type_int32;
  
!   if (strcmp (id, "int64") == 0)
!     return builtin_type_int64;
  
!   if (strcmp (id, "uint8") == 0)
!     return builtin_type_uint8;
  
!   if (strcmp (id, "uint16") == 0)
!     return builtin_type_uint16;
  
!   if (strcmp (id, "uint32") == 0)
!     return builtin_type_uint32;
  
!   if (strcmp (id, "uint64") == 0)
!     return builtin_type_uint64;
  
!   if (strcmp (id, "ieee_single") == 0)
!     return builtin_type_ieee_single;
  
!   if (strcmp (id, "ieee_double") == 0)
!     return builtin_type_ieee_double;
  
!   if (strcmp (id, "arm_fpa_ext") == 0)
!     return builtin_type_arm_ext;
  
    return NULL;
  }
  \f
--- 350,399 ----
    int ix;
    struct type *gdb_type;
  
!   if (id)
!     {
!       /* First try target-defined types.  */
!       for (ix = 0; VEC_iterate (type_p, feature->types, ix, gdb_type); ix++)
! 	if (strcmp (TYPE_NAME (gdb_type), id) == 0)
! 	  return gdb_type;
  
!       /* Next try some predefined types.  Note that none of these
! 	 types depend on the current architecture; some of the
! 	 builtin_type_foo variables are swapped based on the
! 	 architecture.  */
!       if (strcmp (id, "int8") == 0)
! 	return builtin_type_int8;
  
!       if (strcmp (id, "int16") == 0)
! 	return builtin_type_int16;
  
!       if (strcmp (id, "int32") == 0)
! 	return builtin_type_int32;
  
!       if (strcmp (id, "int64") == 0)
! 	return builtin_type_int64;
  
!       if (strcmp (id, "uint8") == 0)
! 	return builtin_type_uint8;
  
!       if (strcmp (id, "uint16") == 0)
! 	return builtin_type_uint16;
  
!       if (strcmp (id, "uint32") == 0)
! 	return builtin_type_uint32;
  
!       if (strcmp (id, "uint64") == 0)
! 	return builtin_type_uint64;
  
!       if (strcmp (id, "ieee_single") == 0)
! 	return builtin_type_ieee_single;
  
!       if (strcmp (id, "ieee_double") == 0)
! 	return builtin_type_ieee_double;
  
+       if (strcmp (id, "arm_fpa_ext") == 0)
+ 	return builtin_type_arm_ext;
+     }
    return NULL;
  }
  \f

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-07-03  1:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-28 21:12 [PATCH] null pointer guard, target-descriptions.c msnyder
2007-07-01 16:00 ` Daniel Jacobowitz
2007-07-03  0:40   ` msnyder
2007-07-03  1:23     ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox