mirror of
https://github.com/LibreOffice/core.git
synced 2025-08-15 20:47:46 +00:00
ofz#415190397 avoid OOM
with huge amounts of error cells Change-Id: I7587063de5914030f7231e91643202f0f4782847 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185408 Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com> Tested-by: Jenkins
This commit is contained in:
@ -40,7 +40,7 @@ public:
|
||||
|
||||
StrData();
|
||||
};
|
||||
static void PutData( ScDocument& rDoc, SCCOL nCol, SCROW nRow, SCTAB nTab,
|
||||
static bool PutData( ScDocument& rDoc, SCCOL nCol, SCROW nRow, SCTAB nTab,
|
||||
const css::uno::Reference< css::sdbc::XRow>& xRow,
|
||||
sal_Int32 nRowPos,
|
||||
tools::Long nType, bool bCurrency, StrData* pStrData = nullptr );
|
||||
|
@ -35,7 +35,7 @@ ScDatabaseDocUtil::StrData::StrData() :
|
||||
{
|
||||
}
|
||||
|
||||
void ScDatabaseDocUtil::PutData(ScDocument& rDoc, SCCOL nCol, SCROW nRow, SCTAB nTab,
|
||||
bool ScDatabaseDocUtil::PutData(ScDocument& rDoc, SCCOL nCol, SCROW nRow, SCTAB nTab,
|
||||
const uno::Reference<sdbc::XRow>& xRow, sal_Int32 nRowPos,
|
||||
tools::Long nType, bool bCurrency, StrData* pStrData)
|
||||
{
|
||||
@ -196,6 +196,7 @@ void ScDatabaseDocUtil::PutData(ScDocument& rDoc, SCCOL nCol, SCROW nRow, SCTAB
|
||||
else
|
||||
rDoc.SetEmptyCell(aPos);
|
||||
}
|
||||
return bError;
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <tools/urlobj.hxx>
|
||||
#include <svl/converter.hxx>
|
||||
#include <svl/numformat.hxx>
|
||||
#include <comphelper/configuration.hxx>
|
||||
#include <comphelper/processfactory.hxx>
|
||||
#include <comphelper/propertysequence.hxx>
|
||||
#include <comphelper/types.hxx>
|
||||
@ -383,6 +384,7 @@ ErrCode ScDocShell::DBaseImport( const OUString& rFullFileName, rtl_TextEncoding
|
||||
|
||||
SCROW nRow = 1; // 0 is column titles
|
||||
bool bEnd = false;
|
||||
size_t nErrors(0);
|
||||
while ( !bEnd && xRowSet->next() )
|
||||
{
|
||||
if (nRow <= m_pDocument->MaxRow())
|
||||
@ -392,10 +394,14 @@ ErrCode ScDocShell::DBaseImport( const OUString& rFullFileName, rtl_TextEncoding
|
||||
for (sal_Int32 i=0; i<nColCount; i++)
|
||||
{
|
||||
ScDatabaseDocUtil::StrData aStrData;
|
||||
ScDatabaseDocUtil::PutData( *m_pDocument, nCol, nRow, 0,
|
||||
bool bWasError =
|
||||
ScDatabaseDocUtil::PutData( *m_pDocument, nCol, nRow, 0,
|
||||
xRow, i+1, pTypeArr[i], false,
|
||||
&aStrData );
|
||||
|
||||
if (bWasError)
|
||||
++nErrors;
|
||||
|
||||
if (aStrData.mnStrLength > aColWidthParam[nCol].mnMaxTextLen)
|
||||
{
|
||||
aColWidthParam[nCol].mnMaxTextLen = aStrData.mnStrLength;
|
||||
@ -410,6 +416,12 @@ ErrCode ScDocShell::DBaseImport( const OUString& rFullFileName, rtl_TextEncoding
|
||||
|
||||
++nCol;
|
||||
}
|
||||
if (nErrors > 65535 && comphelper::IsFuzzing())
|
||||
{
|
||||
bEnd = true;
|
||||
nErr = ERRCODE_IO_GENERAL;
|
||||
SAL_WARN("sc", "Too many errors: abandoning.");
|
||||
}
|
||||
if (!bSimpleRow)
|
||||
rRowHeightsRecalc.setTrue(nRow, nRow);
|
||||
++nRow;
|
||||
|
Reference in New Issue
Block a user