[patch] mi-cmd-var.c validate type

Vladimir Prus ghost@cs.msu.su
Fri Jul 27 21:44:00 GMT 2007


msnyder@sonic.net wrote:

> One of the few places that "type" is checked for null before being
> passed to check_typedef.  According to the comment, it should be
> checked here too.
> mitype.txt
>   2007-07-26  Michael Snyder  <msnyder@access-company.com>
> 
> * mi/mi-cmd-var.c (mi_print_value_p): Return 0 if no type.
> 
> Index: mi/mi-cmd-var.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/mi/mi-cmd-var.c,v
> retrieving revision 1.33
> diff -p -r1.33 mi-cmd-var.c
> *** mi/mi-cmd-var.c     13 Jun 2007 19:08:47 -0000      1.33
> --- mi/mi-cmd-var.c     26 Jul 2007 23:07:38 -0000
> *************** mi_print_value_p (struct type *type, enu
> *** 341,347 ****
> /* For PRINT_SIMPLE_VALUES, only print the value if it has a type
> and that type is not a compound type.  */
> 
> !   return (TYPE_CODE (type) != TYPE_CODE_ARRAY
> && TYPE_CODE (type) != TYPE_CODE_STRUCT
> && TYPE_CODE (type) != TYPE_CODE_UNION);

I'd suspect the comment's bogus, in light of this comment in varobj.c

  /* The type of this variable. This may NEVER be NULL. */
  struct type *type;

I think mi_print_value_p can either assume type is not NULL, or
gdb_assert that.

- Volodya




More information about the Gdb-patches mailing list