diff options
author | John Hodge <tpg@ucc.asn.au> | 2017-11-26 10:59:23 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2017-11-26 10:59:23 +0800 |
commit | 7ca433200a46434ea785881010c476520d6ea746 (patch) | |
tree | 2ebbf8b1165e62b0f214cc726f60e5a113512a08 | |
parent | c9941f4121eaa71066852ae7f600c8fe25c9558e (diff) | |
download | mrust-7ca433200a46434ea785881010c476520d6ea746.tar.gz |
HIR Const Eval - Fix crash with use-after-free in TU
-rw-r--r-- | src/hir_conv/constant_evaluation.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/hir_conv/constant_evaluation.cpp b/src/hir_conv/constant_evaluation.cpp index 09b60fb4..f3d23c47 100644 --- a/src/hir_conv/constant_evaluation.cpp +++ b/src/hir_conv/constant_evaluation.cpp @@ -674,17 +674,18 @@ namespace { ERROR(sp, E0000, "Field access on invalid literal type - " << val.tag_str()); auto& vals = val.as_List(); - TU_MATCH_DEF( ::HIR::TypeRef::Data, (m_rv_type.m_data), (e), + ::HIR::TypeRef ty = mv$(m_rv_type); + TU_MATCH_DEF( ::HIR::TypeRef::Data, (ty.m_data), (e), ( - ERROR(sp, E0000, "Field access on invalid type - " << m_rv_type); + ERROR(sp, E0000, "Field access on invalid type - " << ty); ), (Path, TU_MATCHA( (e.binding), (pbe), (Unbound, - ERROR(sp, E0000, "Field access on invalid type - " << m_rv_type); + ERROR(sp, E0000, "Field access on invalid type - " << ty); ), (Opaque, - ERROR(sp, E0000, "Field access on invalid type - " << m_rv_type); + ERROR(sp, E0000, "Field access on invalid type - " << ty); ), (Struct, auto monomorph_cb = monomorphise_type_get_cb(sp, nullptr, &e.path.m_data.as_Generic().m_params, nullptr); @@ -692,7 +693,7 @@ namespace { unsigned int idx=0; TU_MATCHA( (str.m_data), (se), (Unit, - ERROR(sp, E0000, "Field access on invalid type - " << m_rv_type << " - Unit-like"); + ERROR(sp, E0000, "Field access on invalid type - " << ty << " - Unit-like"); ), (Tuple, idx = ::std::atoi( node.m_field.c_str() ); @@ -709,10 +710,10 @@ namespace { m_rv = mv$( vals[idx] ); ), (Enum, - TODO(sp, "Field access on enum variant - " << m_rv_type); + TODO(sp, "Field access on enum variant - " << ty); ), (Union, - TODO(sp, "Field access on union - " << m_rv_type); + TODO(sp, "Field access on union - " << ty); ) ) ), |