This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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: Bounds checking for TREE_VEC_ELT and related bugs (PR c++/8511)


Zack Weinberg <zack@codesourcery.com> writes:

| Note that tree_vec_elt_check_failed adds one to the index, because it
| was too damn confusing seeing 'accessed elt 2 of tree_vec with 2 elts'
| and having to remember that elt 2 is the third one.

Not a major comment, but maybe `accessed elt at index 2 of tree_vec
of length 2 elts' would also do.

[...]

| Index: cp/pt.c
| --- cp/pt.c	9 Nov 2002 11:53:16 -0000	1.630
| +++ cp/pt.c	14 Nov 2002 19:54:51 -0000
| @@ -6539,7 +6539,8 @@ tsubst (t, args, complain, in_decl)
|  	    tree arg = NULL_TREE;
|  
|  	    levels = TMPL_ARGS_DEPTH (args);
| -	    if (level <= levels)
| +	    if (level <= levels
| +		&& idx < NUM_TMPL_ARGS (TMPL_ARGS_LEVEL (args, level)))
|  	      arg = TMPL_ARG (args, level, idx);

I think this bit is OK.

| Index: cp/search.c
| --- cp/search.c	4 Nov 2002 01:45:55 -0000	1.240
| +++ cp/search.c	14 Nov 2002 19:54:51 -0000
| @@ -2544,7 +2544,8 @@ dfs_push_decls (binfo, data)
|  	  
|        method_vec = (CLASS_TYPE_P (type) 
|  		    ? CLASSTYPE_METHOD_VEC (type) : NULL_TREE);
| -      if (method_vec)
| +
| +      if (method_vec && TREE_VEC_LENGTH (method_vec) >= 3)

I would probably put an assert here is if we have a method_vec then it
size ought to be at least 3.

-- Gaby


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