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] varobj.c (cplus_describe_child): Bail out on error.


msnyder@sonic.net wrote:

> If we don't bail out here, we will pass a null pointer to xstrdup.
> 304.txt
>   2007-08-04 ÂMichael Snyder Â<msnyder@access-company.com>
> 
> * varobj.c (cplus_describe_child): Bail out on error.
> 
> Index: varobj.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/varobj.c,v
> retrieving revision 1.89
> diff -p -r1.89 varobj.c
> *** varobj.cÂÂÂÂ14 Apr 2007 09:51:29 -0000ÂÂÂÂÂÂ1.89
> --- varobj.cÂÂÂÂ5 Aug 2007 00:16:42 -0000
> *************** cplus_describe_child (struct varobj *par
> *** 2395,2401 ****
> }
> else
> {
> ! ÂÂÂÂÂÂ Âchar *access = 0;
> int children[3];
> cplus_class_num_children (type, children);
> 
> --- 2396,2402 ----
> }
> else
> {
> ! ÂÂÂÂÂÂ Âchar *access = NULL;
> int children[3];
> cplus_class_num_children (type, children);
> 
> *************** cplus_describe_child (struct varobj *par
> *** 2432,2438 ****
> break;
> default:
> /* error! */
> ! ÂÂÂÂÂÂ Â Â Âbreak;
> }
> 
> if (cname)
> --- 2433,2439 ----
> break;
> default:
> /* error! */
> ! ÂÂÂÂÂÂ Â Â Âreturn;

If we return here, then name_of_child will return NULL, which is
hardly of good use in future. I'd prefer

        gdb_assert (access);

right after the switch.

Thanks,
Volodya



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