diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-10-14 16:00:25 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-10-14 19:50:06 +0200 |
commit | aefeac247f9b201f1a28a8256421b3dacebafdd3 (patch) | |
tree | 33e4b3dbfaef20c6844467a8b97ecae9ee9004a9 /sc | |
parent | d2b88e12cbe83732b81ee9e133ee96f3295e9d11 (diff) |
ofz#3634: add a SC_MAX_MATRIX_ELEMENTS to limit max matrix elements
Change-Id: Ib2b1a36d56cc8ac63cf28a18fa20ad2f075dcf21
Reviewed-on: https://gerrit.libreoffice.org/43394
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/tool/scmatrix.cxx | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx index 2de6ea8d5c52..c012bc8dcd89 100644 --- a/sc/source/core/tool/scmatrix.cxx +++ b/sc/source/core/tool/scmatrix.cxx @@ -2758,7 +2758,13 @@ bool ScMatrix::IsSizeAllocatable( SCSIZE nC, SCSIZE nR ) SAL_WARN( "sc.core", "ScMatrix one-dimensional zero: " << nC << " columns * " << nR << " rows"); return false; } - if (nC && nR && (nC > (ScMatrix::GetElementsMax() / nR))) + if (!nC || !nR) + return true; + + static size_t nElementsMax = std::getenv("SC_MAX_MATRIX_ELEMENTS") ? std::atoi(std::getenv("SC_MAX_MATRIX_ELEMENTS")) + : ScMatrix::GetElementsMax(); + + if (nC > (nElementsMax / nR)) { SAL_WARN( "sc.core", "ScMatrix overflow: " << nC << " columns * " << nR << " rows"); return false; |