public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-5956] c++: Fix a compile time memory leak in finish_static_assert
@ 2023-11-29  8:21 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2023-11-29  8:21 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:77f0e4a02df15ef4e31b144e8e4bc1a0aa76c416

commit r14-5956-g77f0e4a02df15ef4e31b144e8e4bc1a0aa76c416
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Nov 29 09:19:02 2023 +0100

    c++: Fix a compile time memory leak in finish_static_assert
    
    On Tue, Nov 28, 2023 at 11:31:48AM -0500, Jason Merrill wrote:
    > Jonathan pointed out elsewhere that this gets leaked if error return
    > prevents us from getting to the XDELETEVEC.
    
    As there is a single error return in which it can leak, I've just added
    a XDELETEVEC (buf); statement to that path rather than introducing some
    RAII solution.
    
    2023-11-29  Jakub Jelinek  <jakub@redhat.com>
    
            * semantics.cc (finish_static_assert): Free buf on error return.

Diff:
---
 gcc/cp/semantics.cc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc
index 3bf586453dc..d30a3f99c04 100644
--- a/gcc/cp/semantics.cc
+++ b/gcc/cp/semantics.cc
@@ -11582,6 +11582,7 @@ finish_static_assert (tree condition, tree message, location_t location,
 			  error_at (location,
 				    "%<static_assert%> message %<data()[%d]%> "
 				    "must be a constant expression", i);
+			  XDELETEVEC (buf);
 			  return;
 			}
 		      if (msg == NULL)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-11-29  8:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-29  8:21 [gcc r14-5956] c++: Fix a compile time memory leak in finish_static_assert Jakub Jelinek

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).