Fix export test crash of ooo95715-1.xls

Negative sheet number injected by
sc::FormulaLogger::GroupScope::addRefMessage() wans't handled by lcl_Format()

	#9  0x00007f292172c322 in ScGroupTokenConverter::convert (this=0x7ffc5b1940d0, rCode=..., rScope=...)
		at /build/libo/dev/sc/source/core/data/grouptokenconverter.cxx:140
	#8  0x00007f29224c54d8 in sc::FormulaLogger::GroupScope::addRefMessage (this=0x7ffc5b193ff0, rCellPos=...,
		rRefPos=..., nLen=111, rArray=...) at /build/libo/dev/sc/source/core/tool/formulalogger.cxx:147
	#7  0x00007f292181c071 in ScRange::Format (this=0x7ffc5b193dc0, nFlags=-32760, pDoc=0x4b1db70, rDetails=...,
		bFullAddressNotation=false) at /build/libo/dev/sc/source/core/tool/address.cxx:2211
	#6  0x00007f292181b9a9 in ScAddress::Format (this=0x7ffc5b193dc0, nFlags=-32760, pDoc=0x4b1db70, rDetails=...)
		at /build/libo/dev/sc/source/core/tool/address.cxx:2111
	#5  0x00007f292181ecf5 in lcl_Format<rtl::OUStringBuffer> (r="", nTab=-1, nRow=75, nCol=0, nFlags=-30968,
		pDoc=0x4b1db70, rDetails=...) at /build/libo/dev/sc/source/core/tool/address.cxx:2018
	#4  0x00007f29214471fb in rtl::OUString::operator[] (this=0x7ffc5b193c00, index=0)
		at /build/libo/dev/include/rtl/ustring.hxx:668

Change-Id: I68ecfb11574644e9e5670431789ee42d37d27523
This commit is contained in:
Eike Rathke
2017-07-14 14:34:28 +02:00
parent 5850debba4
commit 62ee21cb46

View File

@@ -2005,7 +2005,7 @@ template<typename T > inline void lcl_Format( T& r, SCTAB nTab, SCROW nRow, SCCO
nFlags |= ( ScRefFlags::ROW_VALID | ScRefFlags::COL_VALID | ScRefFlags::TAB_VALID );
if( pDoc && (nFlags & ScRefFlags::TAB_VALID ) )
{
if ( nTab >= pDoc->GetTableCount() )
if ( nTab < 0 || nTab >= pDoc->GetTableCount() )
{
lcl_string_append(r, ScGlobal::GetRscString( STR_NOREF_STR ));
return;