summaryrefslogtreecommitdiff
path: root/idlc
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2017-07-16 21:22:13 +0200
committerStephan Bergmann <sbergman@redhat.com>2017-07-16 21:22:13 +0200
commitc52cd532b6eea9f32d6d6745818b27adcbf91b16 (patch)
treea837ade4be2ae097bacf2979d49777be604431b1 /idlc
parente4faf5502db93af263c7c746f6e79cbb185b1644 (diff)
Fix lifecycle issue
...as shown by ASan/UBSan build use-after-free report at <https://ci.libreoffice.org/job/lo_ubsan/602/> after 8e39ef66928a3e37c618d3a70a631e71266db274 "extend loplugin useuniqueptr to POD types" Change-Id: Ic42e408c2c4b2901cdf5d681b332543ec8f445ef
Diffstat (limited to 'idlc')
-rw-r--r--idlc/inc/astexpression.hxx2
-rw-r--r--idlc/source/astexpression.cxx8
2 files changed, 6 insertions, 4 deletions
diff --git a/idlc/inc/astexpression.hxx b/idlc/inc/astexpression.hxx
index eec117379b6f..e9e92600bad8 100644
--- a/idlc/inc/astexpression.hxx
+++ b/idlc/inc/astexpression.hxx
@@ -122,7 +122,7 @@ private:
std::unique_ptr<AstExprValue> eval_bin_op();
std::unique_ptr<AstExprValue> eval_bit_op();
std::unique_ptr<AstExprValue> eval_un_op();
- AstExprValue* eval_symbol();
+ std::unique_ptr<AstExprValue> eval_symbol();
OString m_fileName; // fileName defined in
diff --git a/idlc/source/astexpression.cxx b/idlc/source/astexpression.cxx
index 0840ccf756d9..8ec1f63b49df 100644
--- a/idlc/source/astexpression.cxx
+++ b/idlc/source/astexpression.cxx
@@ -23,6 +23,7 @@
#include <astscope.hxx>
#include <errorhandler.hxx>
+#include <o3tl/make_unique.hxx>
#include <osl/diagnose.h>
#include <limits.h>
@@ -817,7 +818,7 @@ void AstExpression::evaluate()
m_exprValue = eval_un_op();
break;
case ExprComb::Symbol:
- m_exprValue.reset( eval_symbol() );
+ m_exprValue = eval_symbol();
break;
case ExprComb::NONE:
break;
@@ -945,7 +946,7 @@ std::unique_ptr<AstExprValue> AstExpression::eval_un_op()
return retval;
}
-AstExprValue* AstExpression::eval_symbol()
+std::unique_ptr<AstExprValue> AstExpression::eval_symbol()
{
AstScope *pScope = nullptr;
AstDeclaration *pDecl;
@@ -996,7 +997,8 @@ AstExprValue* AstExpression::eval_symbol()
*/
pConst = static_cast< AstConstant* >(pDecl);
pConst->getConstValue()->evaluate();
- return pConst->getConstValue()->getExprValue();
+ auto const val = pConst->getConstValue()->getExprValue();
+ return val == nullptr ? nullptr : o3tl::make_unique<AstExprValue>(*val);
}
OString AstExpression::toString()