public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: Patrick Palka <ppalka@redhat.com>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] c++: don't leak 'arglist' in build_new_op
Date: Mon, 13 Dec 2021 10:03:39 -0500	[thread overview]
Message-ID: <196e0bc1-50f4-2d51-89de-da85602741ea@redhat.com> (raw)
In-Reply-To: <20211210162156.3337828-1-ppalka@redhat.com>

On 12/10/21 11:21, Patrick Palka wrote:
> 'arglist' can be captured by a conversion within 'candidates', but if we
> use a releasing_vec then we'll be sure to free it only after
> 'candidates' is freed by obstack_free.
> 
> Bootstrapped and regtested in x86_64-pc-linux-gnu, does this look OK for
> trunk?

OK.

> gcc/cp/ChangeLog:
> 
> 	* call.c (build_new_op): Use releasing_vec for arglist.  Declare
> 	conv in the scope it's used.
> ---
>   gcc/cp/call.c | 6 ++----
>   1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/gcc/cp/call.c b/gcc/cp/call.c
> index 28bd8e0c260..347df5da35d 100644
> --- a/gcc/cp/call.c
> +++ b/gcc/cp/call.c
> @@ -6461,13 +6461,12 @@ build_new_op (const op_location_t &loc, enum tree_code code, int flags,
>   	      tsubst_flags_t complain)
>   {
>     struct z_candidate *candidates = 0, *cand;
> -  vec<tree, va_gc> *arglist;
> +  releasing_vec arglist;
>     tree result = NULL_TREE;
>     bool result_valid_p = false;
>     enum tree_code code2 = ERROR_MARK;
>     enum tree_code code_orig_arg1 = ERROR_MARK;
>     enum tree_code code_orig_arg2 = ERROR_MARK;
> -  conversion *conv;
>     void *p;
>     bool strict_p;
>     bool any_viable_p;
> @@ -6543,7 +6542,6 @@ build_new_op (const op_location_t &loc, enum tree_code code, int flags,
>         arg2_type = integer_type_node;
>       }
>   
> -  vec_alloc (arglist, 3);
>     arglist->quick_push (arg1);
>     if (arg2 != NULL_TREE)
>       arglist->quick_push (arg2);
> @@ -6814,7 +6812,7 @@ build_new_op (const op_location_t &loc, enum tree_code code, int flags,
>   	     corresponding parameters of the selected operation function,
>   	     except that the second standard conversion sequence of a
>   	     user-defined conversion sequence (12.3.3.1.2) is not applied."  */
> -	  conv = cand->convs[0];
> +	  conversion *conv = cand->convs[0];
>   	  if (conv->user_conv_p)
>   	    {
>   	      conv = strip_standard_conversion (conv);


      reply	other threads:[~2021-12-13 15:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-10 16:21 Patrick Palka
2021-12-13 15:03 ` Jason Merrill [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=196e0bc1-50f4-2d51-89de-da85602741ea@redhat.com \
    --to=jason@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=ppalka@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).