Kaydet (Commit) 8f2d3c47 authored tarafından Markus Mohrhard's avatar Markus Mohrhard

don't create uno::Sequence with new, fdo#46825

The uno::Sequence copy c'tor creates a flat copy and increments the ref
count. So if you use new and later delete together with the copy
constructor you get a double delete.
üst 5e8628e4
......@@ -729,9 +729,9 @@ SvXMLImportContext* SchXMLTableCellContext::CreateChildContext(
if( nPrefix == XML_NAMESPACE_TEXT && IsXMLToken( rLocalName, XML_LIST ) && mbReadText )
{
SchXMLCell& rCell = mrTable.aData[ mrTable.nRowIndex ][ mrTable.nColumnIndex ];
rCell.pComplexString = new Sequence< OUString >();
rCell.aComplexString = Sequence< OUString >();
rCell.eType = SCH_CELL_TYPE_COMPLEX_STRING;
pContext = new SchXMLTextListContext( GetImport(), rLocalName, *rCell.pComplexString );
pContext = new SchXMLTextListContext( GetImport(), rLocalName, rCell.aComplexString );
mbReadText = sal_False;//don't apply text from <text:p>
}
// <text:p> element - read text (and range from text:id old version)
......@@ -771,12 +771,12 @@ void lcl_ApplyCellToComplexLabel( const SchXMLCell& rCell, Sequence< uno::Any >&
rComplexLabel.realloc(1);
rComplexLabel[0] = uno::makeAny( rCell.aString );
}
else if( rCell.pComplexString && rCell.eType == SCH_CELL_TYPE_COMPLEX_STRING )
else if( rCell.aComplexString.getLength() && rCell.eType == SCH_CELL_TYPE_COMPLEX_STRING )
{
sal_Int32 nCount = rCell.pComplexString->getLength();
sal_Int32 nCount = rCell.aComplexString.getLength();
rComplexLabel.realloc( nCount );
for( sal_Int32 nN=0; nN<nCount; nN++)
rComplexLabel[nN] = uno::makeAny((*rCell.pComplexString)[nN]);
rComplexLabel[nN] = uno::makeAny((rCell.aComplexString)[nN]);
}
else if( rCell.eType == SCH_CELL_TYPE_FLOAT )
{
......
......@@ -45,17 +45,17 @@ enum SchXMLCellType
struct SchXMLCell
{
rtl::OUString aString;
::com::sun::star::uno::Sequence< rtl::OUString >* pComplexString;
::com::sun::star::uno::Sequence< rtl::OUString > aComplexString;
double fValue;
SchXMLCellType eType;
rtl::OUString aRangeId;
SchXMLCell() : pComplexString(0), fValue( 0.0 ), eType( SCH_CELL_TYPE_UNKNOWN )
SchXMLCell() : aComplexString(), fValue( 0.0 ), eType( SCH_CELL_TYPE_UNKNOWN )
{}
SchXMLCell( const SchXMLCell& rOther )
: aString( rOther.aString )
, pComplexString( rOther.pComplexString ? new ::com::sun::star::uno::Sequence< rtl::OUString >( *rOther.pComplexString ) : 0 )
, aComplexString( rOther.aComplexString )
, fValue( rOther.fValue )
, eType( rOther.eType )
, aRangeId( rOther.aRangeId )
......@@ -63,11 +63,7 @@ struct SchXMLCell
~SchXMLCell()
{
if(pComplexString)
{
delete pComplexString;
pComplexString=0;
}
}
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment