[Libreoffice-commits] core.git: sc/source vcl/workben

Caolán McNamara caolanm at redhat.com
Sat Oct 14 17:50:27 UTC 2017


 sc/source/core/tool/scmatrix.cxx |    8 +++++++-
 vcl/workben/commonfuzzer.hxx     |    1 +
 vcl/workben/fftester.cxx         |    1 +
 3 files changed, 9 insertions(+), 1 deletion(-)

New commits:
commit aefeac247f9b201f1a28a8256421b3dacebafdd3
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sat Oct 14 16:00:25 2017 +0100

    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 at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

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;
diff --git a/vcl/workben/commonfuzzer.hxx b/vcl/workben/commonfuzzer.hxx
index f1079ce7621c..054ea00bfb51 100644
--- a/vcl/workben/commonfuzzer.hxx
+++ b/vcl/workben/commonfuzzer.hxx
@@ -79,6 +79,7 @@ void CommonInitialize(int *argc, char ***argv)
 {
     setenv("SAL_USE_VCLPLUGIN", "svp", 1);
     setenv("JPEGMEM", "768M", 1);
+    setenv("SC_MAX_MATRIX_ELEMENTS", "60000000", 1);
     setenv("SAL_WMF_COMPLEXCLIP_VIA_REGION", "1", 1);
     setenv("SAL_DISABLE_PRINTERLIST", "1", 1);
     setenv("SAL_DISABLE_DEFAULTPRINTER", "1", 1);
diff --git a/vcl/workben/fftester.cxx b/vcl/workben/fftester.cxx
index 581541da7565..a39e3ddc9f2e 100644
--- a/vcl/workben/fftester.cxx
+++ b/vcl/workben/fftester.cxx
@@ -89,6 +89,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
 
         setenv("SAL_USE_VCLPLUGIN", "svp", 1);
         setenv("JPEGMEM", "768M", 1);
+        setenv("SC_MAX_MATRIX_ELEMENTS", "60000000", 1);
         setenv("SAL_WMF_COMPLEXCLIP_VIA_REGION", "1", 1);
         setenv("SAL_DISABLE_PRINTERLIST", "1", 1);
         setenv("SAL_DISABLE_DEFAULTPRINTER", "1", 1);


More information about the Libreoffice-commits mailing list