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] ada-lang.c, null pointer


Hi Michael,

> 2007-08-11  Michael Snyder  <msnyder@access-company.com>
> 
> 	* ada-lang.c (field_alignment): Guard against NULL.

Thanks again for your patch.

May I propose another patch that is very close in spirit? The diff
is slightly bigger, but it makes the code check for a null name
only once, and allows us to know at a glance what we do in this case.

Let me know what you think.
(proposed patch reg-tested)

> Index: ada-lang.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/ada-lang.c,v
> retrieving revision 1.100
> diff -p -r1.100 ada-lang.c
> *** ada-lang.c	6 Aug 2007 20:07:44 -0000	1.100
> --- ada-lang.c	11 Aug 2007 20:25:00 -0000
> *************** field_alignment (struct type *type, int 
> *** 6119,6125 ****
>     int len = (name == NULL) ? 0 : strlen (name);
>     int align_offset;
>   
> !   if (!isdigit (name[len - 1]))
>       return 1;
>   
>     if (isdigit (name[len - 2]))
> --- 6119,6125 ----
>     int len = (name == NULL) ? 0 : strlen (name);
>     int align_offset;
>   
> !   if (name == NULL || !isdigit (name[len - 1]))
>       return 1;
>   
>     if (isdigit (name[len - 2]))



-- 
Joel

Attachment: ada-lang.c.diff
Description: Text document


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