public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Thomas Schwinge <tschwinge@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc/devel/rust/master] libproc_macro: Fix literal drop function
Date: Tue,  2 May 2023 07:09:42 +0000 (GMT)	[thread overview]
Message-ID: <20230502070942.B4A44385773B@sourceware.org> (raw)

https://gcc.gnu.org/g:aa108c21644dfa793a39b59851531f5edf4d2196

commit aa108c21644dfa793a39b59851531f5edf4d2196
Author: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Date:   Fri Apr 21 12:00:08 2023 +0200

    libproc_macro: Fix literal drop function
    
    Fix drop function by changing the delete operator to delete[] in order
    to avoid undefined behaviors.
    
    ChangeLog:
    
            * libgrust/libproc_macro/literal.cc (Literal::drop): Change
            delete operator to delete[].
    
    Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>

Diff:
---
 libgrust/libproc_macro/literal.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libgrust/libproc_macro/literal.cc b/libgrust/libproc_macro/literal.cc
index 221c57a0da5..d4977533a90 100644
--- a/libgrust/libproc_macro/literal.cc
+++ b/libgrust/libproc_macro/literal.cc
@@ -32,11 +32,11 @@ Literal::drop (Literal *lit)
   switch (lit->tag)
     {
     case STRING:
-      delete lit->payload.string_payload.data;
+      delete[] lit->payload.string_payload.data;
       lit->payload.string_payload.len = 0;
       break;
     case BYTE_STRING:
-      delete lit->payload.byte_string_payload.data;
+      delete[] lit->payload.byte_string_payload.data;
       lit->payload.byte_string_payload.size = 0;
       break;
     case CHAR:

                 reply	other threads:[~2023-05-02  7:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20230502070942.B4A44385773B@sourceware.org \
    --to=tschwinge@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /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).