tdf#136755 - delete the variable beforehand REDIM
If an array of objects is passed as an argument to ReDim, delete the
variable beforehand.
Change-Id: Ic863a36f5f2aca658df369f95d275aa287edf795
diff --git a/basic/source/comp/dim.cxx b/basic/source/comp/dim.cxx
index 17eef0a..e95e8ee 100644
--- a/basic/source/comp/dim.cxx
+++ b/basic/source/comp/dim.cxx
@@ -431,9 +431,14 @@ void SbiParser::DefVar( SbiOpcode eOp, bool bStatic )
}
else
{
pDef->SetDims( pDim->GetDims() );
SbiExpression aExpr( this, *pDef, std::move(pDim) );
// tdf#136755 - delete the variable beforehand REDIM
SbiExpression aExpr(this, *pDef, nullptr);
aExpr.Gen();
aGen.Gen(bVBASupportOn ? SbiOpcode::ERASE_CLEAR_ : SbiOpcode::ERASE_);
pDef->SetDims( pDim->GetDims() );
SbiExpression aExpr2( this, *pDef, std::move(pDim) );
aExpr2.Gen();
aGen.Gen( SbiOpcode::DCREATE_, pDef->GetId(), pDef->GetTypeId() );
}
}