Skip to content

Fix a dangling reference in FunctionRefTest.cpp #114949

New issue

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

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

Already on GitHub? # to your account

Merged
merged 1 commit into from
Nov 5, 2024

Conversation

hokein
Copy link
Collaborator

@hokein hokein commented Nov 5, 2024

No description provided.

@hokein hokein requested a review from usx95 November 5, 2024 08:15
@llvmbot
Copy link
Member

llvmbot commented Nov 5, 2024

@llvm/pr-subscribers-llvm-adt

Author: Haojian Wu (hokein)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/114949.diff

1 Files Affected:

  • (modified) llvm/unittests/ADT/FunctionRefTest.cpp (+2-2)
diff --git a/llvm/unittests/ADT/FunctionRefTest.cpp b/llvm/unittests/ADT/FunctionRefTest.cpp
index b1819339730370..6ad40406cdf384 100644
--- a/llvm/unittests/ADT/FunctionRefTest.cpp
+++ b/llvm/unittests/ADT/FunctionRefTest.cpp
@@ -60,11 +60,11 @@ TEST(FunctionRefTest, SFINAE) {
 }
 
 TEST(FunctionRefTest, Equality) {
-  function_ref<int()> X = [] { return 1; };
+  const auto Lambda = []() { return 0; };
+  function_ref<int()> X = Lambda;
   function_ref<int()> Y = X;
   EXPECT_EQ(X, Y);
 
-  const auto Lambda = []() { return 0; };
   function_ref<int()> A(Lambda), B(Lambda);
   EXPECT_EQ(A, B);
 }

@hokein hokein merged commit 92574b5 into llvm:main Nov 5, 2024
10 checks passed
@hokein hokein deleted the function-ref-uaf branch November 5, 2024 15:49
PhilippRados pushed a commit to PhilippRados/llvm-project that referenced this pull request Nov 6, 2024
hokein added a commit that referenced this pull request Nov 7, 2024
This helps catch dangling llvm::function_ref references, see #114950,
#114949, #114808, #114789
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants