Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions clang/lib/AST/ExprConstant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could probably construct some examples that break after this change.

fair enough, i am not sure about the change either. wanted to throw it out to get some more thoughts from community.

Could we get a reduced test case?

i hope so. i am still running a creduce, file is still too big though :(

if (!Evaluate(Lit, Info, CLE->getInitializer()))
return false;

Expand Down
Loading