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

Eike Rathke erack at redhat.com
Thu Feb 1 21:14:33 UTC 2018


 sc/source/filter/qpro/qproform.cxx |   33 +++++++++++++++++++++------------
 1 file changed, 21 insertions(+), 12 deletions(-)

New commits:
commit bc697917c79609243305dcecc7aeef2f3776611c
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Feb 1 22:05:19 2018 +0100

    ofz: do not force non-existent parameters into the TokenPool
    
    Apart from that, the hard coded storage order for ocRRI and ocIpmt
    did the same as the general loop, just with a fixed number of
    parameters. Instead, limit the number of arguments for the loop
    for these opcodes.
    
    Change-Id: I378ccaf60da61c1a385555451456d8422ee33c50

diff --git a/sc/source/filter/qpro/qproform.cxx b/sc/source/filter/qpro/qproform.cxx
index 6555a7842037..70dabdedeed8 100644
--- a/sc/source/filter/qpro/qproform.cxx
+++ b/sc/source/filter/qpro/qproform.cxx
@@ -136,20 +136,29 @@ void QProToSc::DoFunc( DefTokenId eOc, sal_uInt16 nArgs, const sal_Char* pExtStr
 
     if( nArgs> 0 )
     {
-        sal_Int16 nLast = nArgs- 1;
-
         if( eOc == ocRRI )
-            aPool << eParam[ 2 ] << ocSep << eParam[ 1 ] << ocSep << eParam[ 0 ];
-        if( eOc == ocIpmt )
-            aPool << eParam[ 3 ] << ocSep << eParam[ 2 ] << ocSep << eParam[ 1 ] << ocSep << eParam[ 0 ];
-        else
         {
-            aPool << eParam[ nLast ];
-            for( nCount = nLast - 1 ; nCount >= 0 ; nCount-- )
-            {
-                if( nCount != -1 )
-                    aPool << ocSep << eParam[ nCount ];
-            }
+            // There should be at least 3 arguments, but with binary crap may not..
+            SAL_WARN_IF( nArgs < 3, "sc.filter","QProToSc::DoFunc - ocRRI expects 3 parameters but got " << nArgs);
+            // Store first 3 parameters to pool in order 2,1,0
+            if (nArgs > 3)
+                nArgs = 3;
+        }
+        else if( eOc == ocIpmt )
+        {
+            // There should be at least 4 arguments, but with binary crap may not..
+            SAL_WARN_IF( nArgs < 4, "sc.filter","QProToSc::DoFunc - ocIpmt expects 4 parameters but got " << nArgs);
+            // Store first 4 parameters to pool in order 3,2,1,0
+            if (nArgs > 3)
+                nArgs = 3;
+        }
+
+        sal_Int16 nLast = nArgs - 1;
+        aPool << eParam[ nLast ];
+        for( nCount = nLast - 1 ; nCount >= 0 ; nCount-- )
+        {
+            if( nCount != -1 )
+                aPool << ocSep << eParam[ nCount ];
         }
     }
 


More information about the Libreoffice-commits mailing list