Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: msnyder@sonic.net
To: gdb-patches@sourceware.org
Subject: [PATCH] null pointer guard, target-descriptions.c
Date: Thu, 28 Jun 2007 21:12:00 -0000	[thread overview]
Message-ID: <17674.12.7.175.2.1183064463.squirrel@webmail.sonic.net> (raw)

[-- 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

             reply	other threads:[~2007-06-28 21:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-28 21:12 msnyder [this message]
2007-07-01 16:00 ` Daniel Jacobowitz
2007-07-03  0:40   ` msnyder
2007-07-03  1:23     ` Daniel Jacobowitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=17674.12.7.175.2.1183064463.squirrel@webmail.sonic.net \
    --to=msnyder@sonic.net \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox