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

Mark Wielaard mark at klomp.org
Mon Jul 1 05:24:54 PDT 2013


 sw/source/filter/ww8/ww8par3.cxx |   16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

New commits:
commit 5c3f673c1ff25c835da6b905a63b36087aaa405e
Author: Mark Wielaard <mark at klomp.org>
Date:   Sun Jun 30 17:07:05 2013 +0200

    Robustify WW8FormulaControl::FormulaRead reading SvStream.
    
    The >>operator of SvStream doesn't initialize a variable if the stream
    is faulty. So initialize the variables before usage to prevent reading
    wrong/random bits.
    
    Change-Id: Ia66dd6d8574c36e7229a58347f2e2c1e0fe2e248
    Reviewed-on: https://gerrit.libreoffice.org/4636
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx
index 6f2375f..e00b6d2 100644
--- a/sw/source/filter/ww8/ww8par3.cxx
+++ b/sw/source/filter/ww8/ww8par3.cxx
@@ -2176,7 +2176,7 @@ void WW8FormulaControl::FormulaRead(SwWw8ControlType nWhich,
 {
     sal_uInt8 nField;
     // nHeaderBype == version
-    sal_uInt32 nHeaderByte;
+    sal_uInt32 nHeaderByte = 0;
 
     // The following is a FFData structure as described in
     // Microsoft's DOC specification (chapter 2.9.78)
@@ -2185,9 +2185,9 @@ void WW8FormulaControl::FormulaRead(SwWw8ControlType nWhich,
 
     // might be better to read the bits as a 16 bit word
     // ( like it is in the spec. )
-    sal_uInt8 bits1;
+    sal_uInt8 bits1 = 0;
     *pDataStream >> bits1;
-    sal_uInt8 bits2;
+    sal_uInt8 bits2 = 0;
     *pDataStream >> bits2;
 
     sal_uInt8 iType = ( bits1 & 0x3 );
@@ -2199,10 +2199,10 @@ void WW8FormulaControl::FormulaRead(SwWw8ControlType nWhich,
 
     sal_uInt8 iRes = (bits1 & 0x7C) >> 2;
 
-    sal_uInt16 cch;
+    sal_uInt16 cch = 0;
     *pDataStream >> cch;
 
-    sal_uInt16 hps;
+    sal_uInt16 hps = 0;
     *pDataStream >> hps;
 
     // xstzName
@@ -2241,9 +2241,9 @@ void WW8FormulaControl::FormulaRead(SwWw8ControlType nWhich,
     {
         bool bAllOk = true;
         // SSTB (see Spec. 2.2.4)
-        sal_uInt16 fExtend;
+        sal_uInt16 fExtend = 0;
         *pDataStream >> fExtend;
-        sal_uInt16 nNoStrings;
+        sal_uInt16 nNoStrings = 0;
 
         // Isn't it that if fExtend isn't 0xFFFF then fExtend actually
         // doesn't exist and we really have just read nNoStrings ( or cData )?
@@ -2252,7 +2252,7 @@ void WW8FormulaControl::FormulaRead(SwWw8ControlType nWhich,
         *pDataStream >> nNoStrings;
 
         // I guess this should be zero ( and we should ensure that )
-        sal_uInt16 cbExtra;
+        sal_uInt16 cbExtra = 0;
         *pDataStream >> cbExtra;
 
         OSL_ENSURE(bAllOk,


More information about the Libreoffice-commits mailing list