[clang] [clang] Fix a use-after-free in expression evaluation (PR #118480)

Ilya Biryukov via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 3 05:26:16 PST 2024


================
@@ -4515,6 +4515,8 @@ handleLValueToRValueConversion(EvalInfo &Info, const Expr *Conv, QualType Type,
       }
 
       APValue Lit;
+      // Make sure we clean up the temporary created below.
+      FullExpressionRAII CleanupTemps(Info);
----------------
ilya-biryukov wrote:

Could we get a reduced test case?

I don't think it's correct to do the cleanups here, we could probably construct some examples that break after this change.

There are `ExprWithCleanups` and various other mechanisms that ensure we do all the cleanups correctly. This delayed evaluation of compound literals might not play well with those cases today, but it's hard to know for sure without understanding the full picture. Having an example would help better understand if there's a fix needed in a different place.

https://github.com/llvm/llvm-project/pull/118480


More information about the cfe-commits mailing list