aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/ByteCode/Interp.cpp
diff options
context:
space:
mode:
authorTimm Baeder <tbaeder@redhat.com>2025-04-28 17:47:30 +0200
committerGitHub <noreply@github.com>2025-04-28 17:47:30 +0200
commitf8724bd873878df81720bdec8b7a9a24f2a40a03 (patch)
treeba72c97a66760495cd7c87d14638041a82fed8e7 /clang/lib/AST/ByteCode/Interp.cpp
parent41ab76bf0aafb35d6d023429560b44637dfb8de6 (diff)
downloadllvm-f8724bd873878df81720bdec8b7a9a24f2a40a03.zip
llvm-f8724bd873878df81720bdec8b7a9a24f2a40a03.tar.gz
llvm-f8724bd873878df81720bdec8b7a9a24f2a40a03.tar.bz2
[clang][bytecode] Check live-ness when calling dtors (#137645)
We can't call a destructor on a dead pointer.
Diffstat (limited to 'clang/lib/AST/ByteCode/Interp.cpp')
-rw-r--r--clang/lib/AST/ByteCode/Interp.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp
index 4d89f23..62b4495 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -1375,6 +1375,9 @@ static bool checkConstructor(InterpState &S, CodePtr OpPC, const Function *Func,
}
bool CheckDestructor(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
+ if (!CheckLive(S, OpPC, Ptr, AK_Destroy))
+ return false;
+
// Can't call a dtor on a global variable.
if (Ptr.block()->isStatic()) {
const SourceInfo &E = S.Current->getSource(OpPC);