summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGDeclCXX.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2015-12-01 01:10:48 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2015-12-01 01:10:48 +0000
commit5a99c49d2e232c3a5076b2f99549ccd595598a4c (patch)
tree7961878cd4a73b96ba7506a7f9cafd199dce4b84 /clang/lib/CodeGen/CGDeclCXX.cpp
parent21ed3b13bd1a9c9d3cca49553cdd7274c4de5993 (diff)
downloadbcm5719-llvm-5a99c49d2e232c3a5076b2f99549ccd595598a4c.tar.gz
bcm5719-llvm-5a99c49d2e232c3a5076b2f99549ccd595598a4c.zip
Fix use-after-free when a C++ thread_local variable gets replaced (because its
type changes when the initializer is attached). Don't hold onto the GlobalVariable*; recompute it from the VarDecl* instead. llvm-svn: 254359
Diffstat (limited to 'clang/lib/CodeGen/CGDeclCXX.cpp')
-rw-r--r--clang/lib/CodeGen/CGDeclCXX.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index df75045c789..adba7316879 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -337,7 +337,7 @@ CodeGenModule::EmitCXXGlobalVarDeclInitFunc(const VarDecl *D,
// FIXME: We only need to register one __cxa_thread_atexit function for the
// entire TU.
CXXThreadLocalInits.push_back(Fn);
- CXXThreadLocalInitVars.push_back(Addr);
+ CXXThreadLocalInitVars.push_back(D);
} else if (PerformInit && ISA) {
EmitPointerToInitFunc(D, Addr, Fn, ISA);
} else if (auto *IPA = D->getAttr<InitPriorityAttr>()) {
OpenPOWER on IntegriCloud