[Libreoffice-commits] core.git: idlc/inc idlc/source
Stephan Bergmann
sbergman at redhat.com
Sun Jul 16 19:25:11 UTC 2017
idlc/inc/astexpression.hxx | 2 +-
idlc/source/astexpression.cxx | 8 +++++---
2 files changed, 6 insertions(+), 4 deletions(-)
New commits:
commit c52cd532b6eea9f32d6d6745818b27adcbf91b16
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Sun Jul 16 21:22:13 2017 +0200
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
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()
More information about the Libreoffice-commits
mailing list