[PATCH] varobj.c (cplus_describe_child): Bail out on error.

Vladimir Prus ghost@cs.msu.su
Sun Aug 5 06:54:00 GMT 2007


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




More information about the Gdb-patches mailing list