From: Jakub Jelinek Date: Wed, 29 Nov 2023 08:19:02 +0000 (+0100) Subject: c++: Fix a compile time memory leak in finish_static_assert X-Git-Tag: basepoints/gcc-15~4183 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=77f0e4a02df15ef4e31b144e8e4bc1a0aa76c416;p=thirdparty%2Fgcc.git 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 * semantics.cc (finish_static_assert): Free buf on error return. --- diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc index 3bf586453dcb..d30a3f99c040 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, "% message % " "must be a constant expression", i); + XDELETEVEC (buf); return; } if (msg == NULL)