summaryrefslogtreecommitdiff
path: root/src/expand/mod.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2017-09-14 23:18:04 +0800
committerJohn Hodge <tpg@mutabah.net>2017-09-14 23:18:04 +0800
commit05b8e0c2ce8a157a72919840a17d49df72aff363 (patch)
tree8b9491d6760566afe6f05a6827f9cc1cfe92b141 /src/expand/mod.cpp
parent57da2d2bd12033aca1c38bbfc1dcf8d6c60b174f (diff)
downloadmrust-05b8e0c2ce8a157a72919840a17d49df72aff363.tar.gz
Expand - Fix use-after-free if an item is deleted
Diffstat (limited to 'src/expand/mod.cpp')
-rw-r--r--src/expand/mod.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/expand/mod.cpp b/src/expand/mod.cpp
index 2ca45d99..57b44479 100644
--- a/src/expand/mod.cpp
+++ b/src/expand/mod.cpp
@@ -332,7 +332,12 @@ struct CExpandExpr:
void visit(::std::unique_ptr<AST::ExprNode>& cnode) {
if(cnode.get())
- Expand_Attrs(cnode->attrs(), AttrStage::Pre, [&](const auto& sp, const auto& d, const auto& a){ d.handle(sp, a, this->crate, cnode); });
+ {
+ auto attrs = mv$(cnode->attrs());
+ Expand_Attrs(attrs, AttrStage::Pre, [&](const auto& sp, const auto& d, const auto& a){ d.handle(sp, a, this->crate, cnode); });
+ if(cnode.get())
+ cnode->attrs() = mv$(attrs);
+ }
if(cnode.get())
{
cnode->visit(*this);